package com.opd.soeghtool;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.hardware.usb.UsbManager;
import android.media.AudioManager;
import android.media.MediaRouter;
import android.net.RouteInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.SystemClock;
import android.provider.Settings;
import android.support.annotation.RequiresApi;
import android.support.constraint.ConstraintLayout;
import android.support.v4.app.NotificationCompat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AbsoluteLayout;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

import com.nostra13.universalimageloader.BuildConfig;

import org.json.JSONArray;
import org.json.JSONException;

import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;

public class FloatMenuService_New extends Service {

    static final String TAG = "SOEFMSN";
    final int MENU_STAY_TIME = 15000;

    private static Handler handler, handlerSystem, handlerStatus, handlerAudio;
    private Message message, message2, messageStatus, messageAudio;
    FMSN_BroadcastReceive fmsnBroadcastReceive;
    ImageView[] img_button;
    ImageView[] img_button_edit;
    ImageView[] img_button_no_use;
    ImageView[] img_button_split;
    ImageView[] img_button_split_edit;
    ImageView iv_kb_button_setting_remove, iv_kb_button_setting_add, iv_kb_setting_direct, iv_kb_setting_direct_edit, iv_btn_setting_kb_ring, iv_btn_setting_kb_ring_split;
    int[] tempCoordinateTbl;
    int[][] tempAttrTbl;
    int[] tempAttrTblEdit;
    int[] tempAttrEvTbl;
    int[] tempAttrEvTblEdit;
    int[] tempAttrEvTblEdit_bk;
    int[] tempAttrTblEdit_bk;
    byte[] tempKbTbl;
    byte[] u8DataBuffer;
    int g_mAutoEventTblUsed = 0, g_mAutoEventTblLen = 0, g_mButtonSplitNum = 0;
    WindowManager windowManager;
    WindowManager.LayoutParams paramsFloatLogo, paramsFloatHide, paramsFloatMenu, paramsKBFloatMenu, paramsBtnPre, paramsDraw, paramsQuickSetting, paramsPositionData, paramsBtnPosEdit, paramsBtnNoUse, paramsMacroEdit, paramsFloatStatus, paramsVirtualMouse;
    LinearLayout float_menu_layout, float_menu_quick_layout, float_menu_setting_layout, float_menu_home_layout, float_menu_visible_layout, float_menu_data_layout, kb_Quick_Setting_Layout, kb_float_menu_layout_save, kb_float_menu_layout_cancel, kb_float_menu_layout_exit;
    LinearLayout kb_position_data_layout, kb_float_menu_layout, iv_kb_button_setting_reserve, kb_float_menu_layout_attr, kb_button_setting_macro_layout, kb_button_setting_macro_sub_layout, layout_button_setting_macro_edit, float_status_layout;
    AbsoluteLayout button_preview_notouch_layout, float_hide_layout, button_pos_edit_layout, button_no_use_list_layout, virtual_mouse_layout;
    RelativeLayout layout_kb_float_quick_mouse_sense_ver, kb_float_quick_setting_audio_layout,layout_kb_float_quick_mouse_factor_hor,layout_kb_float_quick_mouse_factor_ver;
    SeekBar sb_kb_float_quick_mouse_sense_val, sb_kb_float_quick_mouse_sense_ver_val,sb_kb_float_quick_mouse_factor_val,sb_kb_float_quick_mouse_factor_ver_val;
    CheckBox cb_kb_float_quick_setting_audio;
    TextView tv_kb_float_quick_mouse_sense_val, tv_kb_float_quick_mouse_sense_ver_val,tv_kb_float_quick_mouse_factor_val,tv_kb_float_quick_mouse_factor_ver_val;
    RadioButton rb_kb_float_quick_setting_game, rb_kb_float_quick_setting_office;
    Button btn_get_status;
    Button btn_kb_float_position_data_save, btn_kb_float_position_data_load, btn_kb_button_setting_macro_next, btn_kb_button_setting_macro_confirm, btn_kb_attr_setting_pop_macro_load, btn_kb_attr_setting_pop_macro_save, btn_button_setting_macro_edit_cancel, btn_button_setting_macro_edit_confirm;
    ConstraintLayout float_Logo_Layout;
    GlobalVar mGlobalVar;
    ListView lv_button_setting_macro_edit;
    ArrayList<Map<String, Object>> listData;
    MyEditAdapter myEditAdapter;
    ImageView iv_float_menu_visible, iv_kb_button_setting_macro_zoom, iv_float_layout, iv_float_status_layout_switch, iv_float_status_layout_index, iv_float_status_layout_posture, iv_float_status_layout_screen, iv_kb_virtual_mouse_arrow;
    TextView tv_float_menu_visible, tv_kb_button_setting_macro_tip, tv_kb_button_setting_macro_msg, tv_kb_attr_setting_pop_macro_desc;


    //
    private final static int MAX_USER_SET_KEY_NUM = 15;
    ImageView[] iv_shot_help;
    int[] mShotHelpImageIndex;
    int[] mShotHelpImageIndexBackup;
    int mShotHelpImageSelectIndex = 0;

    int g_prvOrientation = 0;
    int panelHeight, panelWidth, start_x = 300, start_y = 300, HDMI_Width = 1920, HDMI_Height = 1080;
    AlertDialog mDialog = null;

    int g_preButtonIndex = 0xffff;
    int g_ringSizeRocker = 0;

    boolean bIsMacro_record = false, bIsSubViewOn = false, g_bIsVirtualEdit = false, bIsMacroChange = false, bIsMacroBackup = false, bIsAutoModeHDMIOut = false, bIsHeadSetPlugIn = false;
    int g_mBtnEditFlag = 0xff, g_mBtnMacroStep = 0;

    int floatLogoSize = 100, mImageHalfSize = 20, mImageHalfSizeEdit = 20, mImgRingSize = 20, mImageHalfSizeDirect = 20;
    boolean bIsFloatLogoShow = false, bIsFloatMenuShow = false, bIsBtnPreShow = false, bIsQuickSettingShow = false, bIsPositionDataShow = false, bIsBtnPosEdit = false, bIsKBFloatMenuShow = false, bIsBtnPreShowTemp = false;
    boolean bIsHalfShow = false, bIsImageAlreadyCreate = false, bIsImageAlreadyCreate1 = false, bIsEmptyIconShow = false, bIsChanged = false, bIsBtnNoUseShow = false, bIsImageInitial = false, bIsFloatStatusShow = false, bIsVirtualMouseShow = false, bIsVirtualMouseShowBackup = false;


    boolean bIsGunHelpOn = false,bIsGunHelpQuickOn = false;
    int mShotHelpIndex = 0, mShotHelpPosture = 0, mStatusTimeOutCounter = 0, mOutPutPollingCounter = 0, mMacroIntervalTime = 200,mGunPositionIndex = 0;


    int xxxx = 0, yyyy = 0;

    MediaRouter mediaRouter;
    AudioManager audioManager;

    @Override
    public void onCreate() {
        super.onCreate();

        WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        DisplayMetrics dm = new DisplayMetrics();
        display.getRealMetrics(dm);
        mGlobalVar = (GlobalVar) getApplication();
        mGlobalVar.setIsFloatServiceRunning(true);
        paramsFloatLogo = new WindowManager.LayoutParams();
        paramsFloatHide = new WindowManager.LayoutParams();
        paramsDraw = new WindowManager.LayoutParams();
        paramsBtnPre = new WindowManager.LayoutParams();
        paramsVirtualMouse = new WindowManager.LayoutParams();
        paramsQuickSetting = new WindowManager.LayoutParams();
        paramsPositionData = new WindowManager.LayoutParams();
        paramsFloatMenu = new WindowManager.LayoutParams();
        paramsKBFloatMenu = new WindowManager.LayoutParams();
        paramsBtnPosEdit = new WindowManager.LayoutParams();
        paramsBtnNoUse = new WindowManager.LayoutParams();
        paramsMacroEdit = new WindowManager.LayoutParams();
        paramsFloatStatus = new WindowManager.LayoutParams();
        windowManager = (WindowManager) getApplication().getSystemService(Context.WINDOW_SERVICE);
        audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        mediaRouter = (MediaRouter) getSystemService(MEDIA_ROUTER_SERVICE);
        paramsVirtualMouse.format = paramsFloatStatus.format = paramsMacroEdit.format = paramsBtnNoUse.format = paramsKBFloatMenu.format = paramsBtnPosEdit.format = paramsPositionData.format = paramsQuickSetting.format = paramsBtnPre.format = paramsDraw.format = paramsFloatMenu.format = paramsFloatLogo.format = PixelFormat.RGBA_8888;
        paramsMacroEdit.flags = paramsBtnNoUse.flags = paramsKBFloatMenu.flags = paramsFloatHide.flags = paramsFloatLogo.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        paramsPositionData.flags = paramsQuickSetting.flags = paramsDraw.flags = paramsFloatMenu.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;//|WindowManager.LayoutParams.FLAG_FULLSCREEN;
        paramsVirtualMouse.flags = paramsFloatStatus.flags = paramsBtnPre.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;//|WindowManager.LayoutParams.FLAG_FULLSCREEN;
        paramsBtnPosEdit.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            paramsVirtualMouse.type = paramsFloatStatus.type = paramsMacroEdit.type = paramsBtnNoUse.type = paramsKBFloatMenu.type = paramsBtnPosEdit.type = paramsFloatHide.type = paramsPositionData.type = paramsQuickSetting.type = paramsBtnPre.type = paramsDraw.type = paramsFloatMenu.type = paramsFloatLogo.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
        } else {
            paramsVirtualMouse.type = paramsFloatStatus.type = paramsMacroEdit.type = paramsBtnNoUse.type = paramsKBFloatMenu.type = paramsBtnPosEdit.type = paramsFloatHide.type = paramsPositionData.type = paramsQuickSetting.type = paramsBtnPre.type = paramsDraw.type = paramsFloatMenu.type = paramsFloatLogo.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            paramsVirtualMouse.layoutInDisplayCutoutMode = paramsFloatStatus.layoutInDisplayCutoutMode = paramsMacroEdit.layoutInDisplayCutoutMode = paramsBtnNoUse.layoutInDisplayCutoutMode = paramsKBFloatMenu.layoutInDisplayCutoutMode = paramsBtnPosEdit.layoutInDisplayCutoutMode = paramsFloatHide.layoutInDisplayCutoutMode = paramsPositionData.layoutInDisplayCutoutMode = paramsFloatLogo.layoutInDisplayCutoutMode = paramsQuickSetting.layoutInDisplayCutoutMode = paramsBtnPre.layoutInDisplayCutoutMode = paramsDraw.layoutInDisplayCutoutMode = paramsFloatMenu.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
        }
        //设置窗口初始停靠位置.
        paramsVirtualMouse.gravity = paramsFloatStatus.gravity = paramsBtnPosEdit.gravity = paramsFloatHide.gravity = paramsQuickSetting.gravity = paramsBtnPre.gravity = paramsDraw.gravity = paramsFloatLogo.gravity = Gravity.START | Gravity.TOP;
        paramsFloatMenu.gravity = Gravity.CENTER | Gravity.TOP;
        paramsKBFloatMenu.gravity = Gravity.CENTER | Gravity.TOP;
        paramsBtnNoUse.gravity = paramsPositionData.gravity = Gravity.CENTER | Gravity.TOP;
        paramsMacroEdit.gravity = Gravity.CENTER | Gravity.TOP;

        img_button = new ImageView[Transfer_Con.MAX_COORDINATE];
        img_button_edit = new ImageView[Transfer_Con.MAX_COORDINATE];
        img_button_no_use = new ImageView[Transfer_Con.MAX_COORDINATE];

        tempCoordinateTbl = new int[Transfer_Con.MAX_COORDINATE * 2];
        tempAttrTbl = new int[Transfer_Con.MAX_COORDINATE][3];
        tempAttrTblEdit = new int[3];
        tempAttrTblEdit_bk = new int[3];
        tempAttrEvTbl = new int[Transfer_Con.MAX_AUTOEVENT_LENGTH_KB];
        tempAttrEvTblEdit = new int[Transfer_Con.MAX_AUTOEVENT_LENGTH_KB];
        tempAttrEvTblEdit_bk = new int[Transfer_Con.MAX_AUTOEVENT_LENGTH_KB];

        u8DataBuffer = new byte[Transfer_Con.HID_PACKET_SIZE];
        tempKbTbl = new byte[5];

        mShotHelpImageIndex = new int[MAX_USER_SET_KEY_NUM];
        mShotHelpImageIndexBackup = new int[MAX_USER_SET_KEY_NUM];

        Log.d(TAG, String.format("wid=%d, hei=%d", dm.widthPixels, dm.heightPixels));
        panelHeight = dm.heightPixels;
        panelWidth = dm.widthPixels;
        Configuration mConfiguration = FloatMenuService_New.this.getResources().getConfiguration();
        g_prvOrientation = mConfiguration.orientation;

        if (panelWidth < panelHeight) {
            int a = panelWidth;
            panelWidth = panelHeight;
            panelHeight = a;
            Log.d(TAG, "swap to Landscape Mode");
            if (g_prvOrientation == Configuration.ORIENTATION_PORTRAIT)
                g_prvOrientation = Configuration.ORIENTATION_LANDSCAPE;
            //Toast.makeText(FloatMenuService_New.this,String.format("ori=%d,wid=%d,hei=%d",g_prvOrientation,panelWidth,panelHeight),Toast.LENGTH_SHORT).show();
        }
        if (panelWidth > panelHeight) {
            if (g_prvOrientation == Configuration.ORIENTATION_PORTRAIT)
                g_prvOrientation = Configuration.ORIENTATION_LANDSCAPE;
        }
        if(Transfer_Con.ENABLE_DIFFERENT_RESOLUTION_KB) {

           // mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_SCREEN_RESOLUTION, panelWidth, panelHeight,3);
            /*
            if ((mGlobalVar.getScreenWidth() != panelHeight) && ((panelHeight == 1128) || (panelHeight == 752))) {
                panelHeight = mGlobalVar.getScreenWidth();
            }

            if ((mGlobalVar.getScreenHeight() != panelWidth) && ((panelWidth == 2400) || (panelWidth == 1600))) {
                panelWidth = mGlobalVar.getScreenHeight();
            }
            */
           // if(((mGlobalVar.getScreenWidth() != panelHeight) && ((panelHeight == 1128) || (panelHeight == 752)))||((mGlobalVar.getScreenHeight() != panelWidth) && ((panelWidth == 2400) || (panelWidth == 1600))))


        }
        floatLogoSize = dip2px(this, 30);

        paramsFloatStatus.width = dip2px(this, 80);
        paramsFloatStatus.height = dip2px(this, 20);
        paramsFloatLogo.width = floatLogoSize;
        paramsFloatLogo.height = floatLogoSize;

        paramsFloatHide.x = paramsFloatLogo.x + floatLogoSize + 1;
        paramsFloatHide.width = 10;
        paramsFloatHide.height = 10;

        paramsFloatMenu.width = dip2px(this, 310);
        //paramsFloat.x = panelWidth/2-paramsFloat.width/2;
        //paramsFloat.y = 0;
        paramsFloatMenu.height = dip2px(this, 50);

        paramsKBFloatMenu.width = dip2px(this, 200);
        paramsKBFloatMenu.height = dip2px(this, 50);

        paramsFloatLogo.x = panelWidth / 4;
        paramsFloatStatus.x = paramsFloatLogo.x - paramsFloatStatus.width;
        paramsFloatStatus.y = 1;

        paramsBtnNoUse.y = paramsKBFloatMenu.height + 1;
        paramsBtnNoUse.width = panelWidth / 4;
        paramsBtnNoUse.height = panelHeight / 3;

        paramsBtnPre.width = panelWidth;
        paramsBtnPre.height = panelHeight;

        paramsVirtualMouse.width = panelWidth;
        paramsVirtualMouse.height = panelHeight;
        paramsBtnPosEdit.width = panelWidth;
        paramsBtnPosEdit.height = panelHeight;

        paramsMacroEdit.width = panelWidth;
        paramsMacroEdit.height = panelHeight;

        paramsQuickSetting.width = dip2px(this, 300);
        paramsQuickSetting.x = panelWidth / 2 - paramsQuickSetting.width / 2;
        paramsQuickSetting.y = paramsFloatMenu.height;
        if (Transfer_Con.ENABLE_NEW_USER_INTERFACE) {
            paramsQuickSetting.height = dip2px(this, 80);
        } else {
            if (mGlobalVar.getDeviceIndex() == Transfer_Con.DEVICE_BX2_INDEX)
                paramsQuickSetting.height = dip2px(this, 200);
            else
                paramsQuickSetting.height = dip2px(this, 160);
        }

        paramsPositionData.y = paramsFloatMenu.height;
        paramsPositionData.width = dip2px(this, 300);
        paramsPositionData.height = dip2px(this, 130);

        LayoutInflater inflater = LayoutInflater.from(getApplication());
        float_Logo_Layout = (ConstraintLayout) inflater.inflate(R.layout.float_layout, null);
        float_menu_layout = (LinearLayout) inflater.inflate(R.layout.float_menu_layout, null);
        kb_Quick_Setting_Layout = (LinearLayout) inflater.inflate(R.layout.kb_float_quick_setting_layout, null);
        kb_position_data_layout = (LinearLayout) inflater.inflate(R.layout.kb_float_position_data_layout, null);
        kb_float_menu_layout = (LinearLayout) inflater.inflate(R.layout.kb_float_menu_layout, null);
        float_hide_layout = (AbsoluteLayout) inflater.inflate(R.layout.float_hide_layout, null);
        button_preview_notouch_layout = (AbsoluteLayout) inflater.inflate(R.layout.btn_notouch_layout, null);
        virtual_mouse_layout = (AbsoluteLayout) inflater.inflate(R.layout.kb_virtual_mouse_layout, null);
        button_pos_edit_layout = (AbsoluteLayout) inflater.inflate(R.layout.kb_button_setting_layout, null);
        button_no_use_list_layout = (AbsoluteLayout) inflater.inflate(R.layout.kb_no_use_btn_lst_layout, null);
        layout_button_setting_macro_edit = (LinearLayout) inflater.inflate(R.layout.button_setting_macro_edit_layout, null);
        float_status_layout = (LinearLayout) inflater.inflate(R.layout.float_status_layout, null);

        iv_float_layout = float_Logo_Layout.findViewById(R.id.iv_float_layout);

        float_menu_quick_layout = (LinearLayout) float_menu_layout.findViewById(R.id.ll_float_menu_quick);
        float_menu_setting_layout = (LinearLayout) float_menu_layout.findViewById(R.id.ll_float_menu_setting);
        float_menu_home_layout = (LinearLayout) float_menu_layout.findViewById(R.id.ll_float_menu_home);
        float_menu_visible_layout = (LinearLayout) float_menu_layout.findViewById(R.id.ll_float_menu_visible);
        float_menu_data_layout = (LinearLayout) float_menu_layout.findViewById(R.id.ll_float_menu_data);

        iv_float_menu_visible = float_menu_layout.findViewById(R.id.iv_float_menu_visible);
        tv_float_menu_visible = float_menu_layout.findViewById(R.id.tv_float_menu_visible);

        kb_float_menu_layout_save = (LinearLayout) kb_float_menu_layout.findViewById(R.id.kb_float_menu_layout_save);
        kb_float_menu_layout_cancel = (LinearLayout) kb_float_menu_layout.findViewById(R.id.kb_float_menu_layout_cancel);
        kb_float_menu_layout_exit = (LinearLayout) kb_float_menu_layout.findViewById(R.id.kb_float_menu_layout_exit);
        kb_float_menu_layout_attr = (LinearLayout) kb_float_menu_layout.findViewById(R.id.kb_float_menu_layout_attr);
        //layout_btn_set_add_rmv_kb = (LinearLayout)button_pos_edit_layout.findViewById(R.id.layout_btn_set_add_rmv_kb);

        // Quick Setting
        layout_kb_float_quick_mouse_sense_ver = kb_Quick_Setting_Layout.findViewById(R.id.layout_kb_float_quick_mouse_sense_ver);
        sb_kb_float_quick_mouse_sense_val = kb_Quick_Setting_Layout.findViewById(R.id.sb_kb_float_quick_mouse_sense_val);
        tv_kb_float_quick_mouse_sense_val = kb_Quick_Setting_Layout.findViewById(R.id.tv_kb_float_quick_mouse_sense_val);
        sb_kb_float_quick_mouse_sense_ver_val = kb_Quick_Setting_Layout.findViewById(R.id.sb_kb_float_quick_mouse_sense_ver_val);
        tv_kb_float_quick_mouse_sense_ver_val = kb_Quick_Setting_Layout.findViewById(R.id.tv_kb_float_quick_mouse_sense_ver_val);
        rb_kb_float_quick_setting_game = kb_Quick_Setting_Layout.findViewById(R.id.rb_kb_float_quick_setting_game);
        rb_kb_float_quick_setting_office = kb_Quick_Setting_Layout.findViewById(R.id.rb_kb_float_quick_setting_office);
        kb_float_quick_setting_audio_layout = kb_Quick_Setting_Layout.findViewById(R.id.kb_float_quick_setting_audio_layout);
        cb_kb_float_quick_setting_audio = kb_Quick_Setting_Layout.findViewById(R.id.cb_kb_float_quick_setting_audio);
        btn_get_status = kb_Quick_Setting_Layout.findViewById(R.id.btn_get_status);

        layout_kb_float_quick_mouse_factor_hor = kb_Quick_Setting_Layout.findViewById(R.id.layout_kb_float_quick_mouse_factor_hor);
        layout_kb_float_quick_mouse_factor_ver = kb_Quick_Setting_Layout.findViewById(R.id.layout_kb_float_quick_mouse_factor_ver);
        sb_kb_float_quick_mouse_factor_val = kb_Quick_Setting_Layout.findViewById(R.id.sb_kb_float_quick_mouse_factor_val);
        tv_kb_float_quick_mouse_factor_val = kb_Quick_Setting_Layout.findViewById(R.id.tv_kb_float_quick_mouse_factor_val);
        sb_kb_float_quick_mouse_factor_ver_val = kb_Quick_Setting_Layout.findViewById(R.id.sb_kb_float_quick_mouse_factor_ver_val);
        tv_kb_float_quick_mouse_factor_ver_val = kb_Quick_Setting_Layout.findViewById(R.id.tv_kb_float_quick_mouse_factor_ver_val);
        if (!Transfer_Con.ENABLE_NEW_USER_INTERFACE) {
            if (mGlobalVar.getDeviceIndex() == Transfer_Con.DEVICE_BX2_INDEX)
                kb_float_quick_setting_audio_layout.setVisibility(View.VISIBLE);
        }
        sb_kb_float_quick_mouse_sense_val.setMax(50);
        sb_kb_float_quick_mouse_sense_ver_val.setMax(50);

        sb_kb_float_quick_mouse_factor_val.setMax(200);
        sb_kb_float_quick_mouse_factor_ver_val.setMax(200);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            sb_kb_float_quick_mouse_sense_val.setMin(1);
            sb_kb_float_quick_mouse_sense_ver_val.setMin(1);
            sb_kb_float_quick_mouse_factor_val.setMin(1);
            sb_kb_float_quick_mouse_factor_ver_val.setMin(1);
        }

        iv_kb_button_setting_remove = button_pos_edit_layout.findViewById(R.id.iv_kb_button_setting_remove);
        iv_kb_button_setting_add = button_pos_edit_layout.findViewById(R.id.iv_kb_button_setting_add);
        iv_kb_button_setting_reserve = button_pos_edit_layout.findViewById(R.id.iv_kb_button_setting_reserve);
        iv_btn_setting_kb_ring = button_pos_edit_layout.findViewById(R.id.iv_btn_setting_kb_ring);
        iv_btn_setting_kb_ring_split = button_pos_edit_layout.findViewById(R.id.iv_btn_setting_kb_ring_split);

        kb_button_setting_macro_layout = button_pos_edit_layout.findViewById(R.id.kb_button_setting_macro_layout);
        kb_button_setting_macro_sub_layout = button_pos_edit_layout.findViewById(R.id.kb_button_setting_macro_sub_layout);
        iv_kb_button_setting_macro_zoom = button_pos_edit_layout.findViewById(R.id.iv_kb_button_setting_macro_zoom);
        btn_kb_button_setting_macro_next = button_pos_edit_layout.findViewById(R.id.btn_kb_button_setting_macro_next);
        btn_kb_button_setting_macro_confirm = button_pos_edit_layout.findViewById(R.id.btn_kb_button_setting_macro_confirm);
        tv_kb_button_setting_macro_tip = button_pos_edit_layout.findViewById(R.id.tv_kb_button_setting_macro_tip);
        tv_kb_button_setting_macro_msg = button_pos_edit_layout.findViewById(R.id.tv_kb_button_setting_macro_msg);
        // Data
        btn_kb_float_position_data_load = kb_position_data_layout.findViewById(R.id.btn_kb_float_position_data_load);
        btn_kb_float_position_data_save = kb_position_data_layout.findViewById(R.id.btn_kb_float_position_data_save);

        lv_button_setting_macro_edit = layout_button_setting_macro_edit.findViewById(R.id.lv_button_setting_macro_edit);
        btn_button_setting_macro_edit_cancel = layout_button_setting_macro_edit.findViewById(R.id.btn_button_setting_macro_edit_cancel);
        btn_button_setting_macro_edit_confirm = layout_button_setting_macro_edit.findViewById(R.id.btn_button_setting_macro_edit_confirm);

        // status
        iv_float_status_layout_switch = float_status_layout.findViewById(R.id.iv_float_status_layout_switch);
        iv_float_status_layout_index = float_status_layout.findViewById(R.id.iv_float_status_layout_index);
        iv_float_status_layout_posture = float_status_layout.findViewById(R.id.iv_float_status_layout_posture);
        iv_float_status_layout_screen = float_status_layout.findViewById(R.id.iv_float_status_layout_screen);
        // mouse
        iv_kb_virtual_mouse_arrow = virtual_mouse_layout.findViewById(R.id.iv_kb_virtual_mouse_arrow);

        float_menu_quick_layout.setOnClickListener(onClickListener);
        float_menu_setting_layout.setOnClickListener(onClickListener);
        float_menu_home_layout.setOnClickListener(onClickListener);
        float_menu_visible_layout.setOnClickListener(onClickListener);
        float_menu_data_layout.setOnClickListener(onClickListener);

        kb_float_menu_layout_save.setOnClickListener(onClickListener);
        kb_float_menu_layout_cancel.setOnClickListener(onClickListener);
        kb_float_menu_layout_exit.setOnClickListener(onClickListener);
        kb_float_menu_layout_attr.setOnClickListener(onClickListener);
        iv_kb_button_setting_add.setOnClickListener(onClickListener);
        btn_kb_float_position_data_load.setOnClickListener(onClickListener);
        btn_kb_float_position_data_save.setOnClickListener(onClickListener);
        iv_kb_button_setting_macro_zoom.setOnClickListener(onClickListener);
        btn_kb_button_setting_macro_next.setOnClickListener(onClickListener);
        btn_kb_button_setting_macro_confirm.setOnClickListener(onClickListener);
        btn_button_setting_macro_edit_cancel.setOnClickListener(onClickListener);
        btn_button_setting_macro_edit_confirm.setOnClickListener(onClickListener);


        windowManager.addView(float_Logo_Layout, paramsFloatLogo);
        bIsFloatLogoShow = true;

        windowManager.addView(float_menu_layout, paramsFloatMenu);
        bIsFloatMenuShow = true;

        //windowManager.addView(virtual_mouse_layout, paramsVirtualMouse);
        //bIsVirtualMouseShow = true;


        if (((paramsFloatLogo.x + floatLogoSize / 2) > (panelWidth - paramsFloatMenu.width) / 2) && ((paramsFloatLogo.x - floatLogoSize / 2) < (panelWidth + paramsFloatMenu.width) / 2)) {
            if ((paramsFloatLogo.x) < (panelWidth) / 2)
                paramsFloatLogo.x = (panelWidth - paramsFloatMenu.width) / 2 - floatLogoSize - 2;
            else
                paramsFloatLogo.x = (panelWidth + paramsFloatMenu.width) / 2 + floatLogoSize;
            windowManager.updateViewLayout(float_Logo_Layout, paramsFloatLogo);
        }
        float_menu_layout.setOnTouchListener(onTouchListener);
        float_menu_quick_layout.setOnTouchListener(onTouchListener);
        float_menu_setting_layout.setOnTouchListener(onTouchListener);
        float_menu_home_layout.setOnTouchListener(onTouchListener);
        float_menu_visible_layout.setOnTouchListener(onTouchListener);
        float_menu_data_layout.setOnTouchListener(onTouchListener);

        windowManager.addView(button_preview_notouch_layout, paramsBtnPre);
        bIsBtnPreShow = true;
        bIsBtnPreShowTemp = true;
        iv_float_menu_visible.setImageResource(R.drawable.invisible);
        tv_float_menu_visible.setText(getResources().getString(R.string.string_float_menu_hide));
        //windowManager.addView(button_pos_edit_layout, paramsBtnPosEdit);
        //bIsBtnPosEdit = true;

        tempCoordinateTbl = mGlobalVar.coorTbl.clone();

        for (int k = 0; k < Transfer_Con.MAX_COORDINATE; k++) {
            tempAttrTbl[k][0] = mGlobalVar.attrTbl[k][0];
            tempAttrTbl[k][1] = mGlobalVar.attrTbl[k][1];
            tempAttrTbl[k][2] = mGlobalVar.attrTbl[k][2];
        }
        tempKbTbl = mGlobalVar.kbTbl.clone();
        tempAttrEvTbl = mGlobalVar.attrEvTbl.clone();
        for (int k = 0; k < Transfer_Con.MAX_COORDINATE; k++) {
            if (getIsUseEvTabl(tempAttrTbl[k][0])) {
                if (tempAttrTbl[k][1] >= (g_mAutoEventTblUsed)) {
                    g_mAutoEventTblUsed = tempAttrTbl[k][1] + tempAttrTbl[k][2];

                    if (BuildConfig.DEBUG)
                        Log.d(TAG, String.format("0x%x s=%d,l=%d,used=%d", k, tempAttrTbl[k][1], tempAttrTbl[k][2], g_mAutoEventTblUsed));
                }
            }
        }

        if (BuildConfig.DEBUG) {
            String str = "ww ";
            for (int a = 0; a < Transfer_Con.MAX_COORDINATE * 2; a += 2) {
                str += String.format("%d, %d, ", tempCoordinateTbl[a], tempCoordinateTbl[a + 1]);
            }
            Log.d(TAG, str);
            Log.d(TAG, String.format("aa =%x,%x,%x,%x,%x", tempKbTbl[0], tempKbTbl[1], tempKbTbl[2], tempKbTbl[3], tempKbTbl[4]));
        }
        mImageHalfSize = (int) (((float) dip2px(this, 7) * (mGlobalVar.getNormal_Icon_Size() + 5) / 10));
        mImageHalfSizeEdit = (int) (((float) dip2px(this, 14) * (mGlobalVar.getPt_Tbl_View_Size() + 5) / 10));
        mImageHalfSizeDirect = (int) (((float) dip2px(this, 16) * (mGlobalVar.getNormal_Icon_Size() + 5) / 10));
        showFloatImage();

        iv_kb_button_setting_remove.setX((float) panelWidth / 2 - mImageHalfSizeEdit);
        iv_kb_button_setting_remove.setY(dip2px(FloatMenuService_New.this, 50));

        iv_kb_button_setting_add.setX((float) panelWidth / 2 - dip2px(FloatMenuService_New.this, 150) - mImageHalfSizeEdit * 2);
        iv_kb_button_setting_add.setY(dip2px(FloatMenuService_New.this, 50));


        ViewGroup.LayoutParams lp = iv_kb_button_setting_reserve.getLayoutParams();
        lp.width = mImageHalfSizeEdit * 2 * 8;
        lp.height = mImageHalfSizeEdit * 2 * 7;
        iv_kb_button_setting_reserve.setX((float) panelWidth / 2 - (float) lp.width / 2);//dip2px(FloatMenuService_New.this, 150));
        iv_kb_button_setting_reserve.setY(dip2px(FloatMenuService_New.this, 50));
        //ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(mImageHalfSize * 2, mImageHalfSize * 2);
        //layout_btn_set_add_rmv_kb.setX(start_x);
        //layout_btn_set_add_rmv_kb.setY(start_y);
        //showNormalEmptyBtn(true);
        ViewGroup.LayoutParams adv_lp = kb_button_setting_macro_layout.getLayoutParams();
        kb_button_setting_macro_layout.setX((int) (panelWidth / 4));
        kb_button_setting_macro_layout.setY(dip2px(this, 40));
        adv_lp.width = (int) (panelWidth / 2);
        adv_lp.height = (int) (panelHeight / 2);

        if (mGlobalVar.tranGet_Value_retry(Transfer_Con.HID_CMD_GET_HW_SETTING, 0, 1, u8DataBuffer, 5)) {
            if ((u8DataBuffer[0] & 0x01) == 0x01)
                Toast.makeText(this, "当前鼠标键盘模式为办公模式！快速切换到游戏模式\"CTRL+ALT+F11\"", Toast.LENGTH_SHORT).show();
        }

        mediaRouter.addCallback(MediaRouter.ROUTE_TYPE_LIVE_VIDEO,mMediaRouterCallback);


        if (mGlobalVar.getIsCurDeviceKBBox()) {
            if (mGlobalVar.getIsAutoSwitchToHDMI()) {
                //Log.d(TAG,"-------------------> 自动切换");
                if (getIsHDMIOut()) {
                    mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HDMI_RESOLUTION, HDMI_Width, HDMI_Height, 3);
                    mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x04, 0x04, 3);
                    mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_SCREEN_RESOLUTION, panelWidth, panelHeight,3);
                    //Toast.makeText(FloatMenuService_New.this,String.format("--%d,--%d",HDMI_Width,HDMI_Height),Toast.LENGTH_SHORT).show();
                    //Log.d(TAG,"-------------------> HDMI输出");
                } else {
                    mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x00, 0x04, 3);
                    //Log.d(TAG,"-------------------> 手机输出");
                }

            } else if (mGlobalVar.getIsManualSetToHDMI()) {
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HDMI_RESOLUTION, mGlobalVar.getManualHDMIWidth(), mGlobalVar.getManualHDMIHeight(), 3);
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x04, 0x04, 3);
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_SCREEN_RESOLUTION, panelWidth, panelHeight,3);
                //Log.d(TAG,"-------------------> 手动切换HDMI");
            } else {
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x00, 0x04, 3);
                //Log.d(TAG,"-------------------> 手动切换手机");
            }
            //mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SAVE_DATA, 0x00, 0x00, 1);
        }




        float_Logo_Layout.setOnTouchListener(new View.OnTouchListener() {
            int prev_x = 0, prev_y = 0;

            @Override
            public boolean onTouch(View v, MotionEvent event) {

                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        handler.removeMessages(0);
                        prev_x = (int) event.getRawX();
                        prev_y = (int) event.getRawY();
                        break;
                    case MotionEvent.ACTION_MOVE:
                        if ((Math.abs(prev_x - (int) event.getRawX()) > 20) || ((Math.abs(prev_y - (int) event.getRawY()) > 20))) {
                            paramsFloatLogo.x = (int) event.getRawX() - floatLogoSize / 2;
                            windowManager.updateViewLayout(float_Logo_Layout, paramsFloatLogo);
                        }
                        break;
                    case MotionEvent.ACTION_UP:
                        if (bIsHalfShow) {
                            float_Logo_Layout.scrollBy(0, -floatLogoSize / 2);
                            windowManager.updateViewLayout(float_Logo_Layout, paramsFloatLogo);
                            bIsHalfShow = false;
                        } else {
                            if ((Math.abs(prev_x - (int) event.getRawX()) < 20) && (Math.abs(prev_y - (int) event.getRawY()) < 20)) {
                                if (bIsQuickSettingShow) {
                                    windowManager.removeView(kb_Quick_Setting_Layout);
                                    bIsQuickSettingShow = false;
                                } else if (bIsPositionDataShow) {
                                    bIsPositionDataShow = false;
                                    windowManager.removeView(kb_position_data_layout);
                                } else if (bIsFloatMenuShow) {
                                    windowManager.removeView(float_menu_layout);
                                    bIsFloatMenuShow = false;
                                } else {
                                    if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
                                        if (bIsVirtualMouseShow) {
                                            windowManager.removeView(virtual_mouse_layout);
                                            bIsVirtualMouseShow = false;
                                            bIsVirtualMouseShowBackup = true;
                                        } else {
                                            bIsVirtualMouseShowBackup = false;
                                        }
                                    }
                                    windowManager.addView(float_menu_layout, paramsFloatMenu);
                                    bIsFloatMenuShow = true;
                                    if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
                                        if (bIsVirtualMouseShowBackup) {
                                            windowManager.addView(virtual_mouse_layout, paramsVirtualMouse);
                                            bIsVirtualMouseShow = true;
                                        }
                                    }
                                }
                            }
                        }

                        if (((paramsFloatLogo.x + floatLogoSize / 2) > (panelWidth - paramsFloatMenu.width) / 2) && ((paramsFloatLogo.x - floatLogoSize / 2) < (panelWidth + paramsFloatMenu.width) / 2)) {
                            if ((paramsFloatLogo.x) < (panelWidth) / 2)
                                paramsFloatLogo.x = (panelWidth - paramsFloatMenu.width) / 2 - floatLogoSize - 2;
                            else
                                paramsFloatLogo.x = (panelWidth + paramsFloatMenu.width) / 2 + floatLogoSize;
                            windowManager.updateViewLayout(float_Logo_Layout, paramsFloatLogo);
                        }

                        message = handler.obtainMessage();
                        message.what = 0;
                        message.arg1 = (int) paramsFloatLogo.x;
                        message.arg2 = (int) paramsFloatLogo.y;
                        handler.sendMessageDelayed(message, MENU_STAY_TIME);
                        break;
                }
                return false;
            }
        });

        sb_kb_float_quick_mouse_sense_val.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (progress < 1)
                    progress = 1;
                else if (progress > 50)
                    progress = 50;

                tv_kb_float_quick_mouse_sense_val.setText(String.valueOf(progress));

            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_R_ROCK_MIN, seekBar.getProgress(), 0, 3);
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SAVE_DATA, 0, 0, 3);
                handler.removeMessages(0);
                message = handler.obtainMessage();
                message.what = 0;
                message.arg1 = (int) paramsFloatLogo.x;
                message.arg2 = (int) paramsFloatLogo.y;
                handler.sendMessageDelayed(message, MENU_STAY_TIME);
            }
        });

        sb_kb_float_quick_mouse_sense_ver_val.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (progress < 1)
                    progress = 1;
                else if (progress > 50)
                    progress = 50;

                tv_kb_float_quick_mouse_sense_ver_val.setText(String.valueOf(progress));

            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_R_ROCK_MAX, seekBar.getProgress(), 0, 3);
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SAVE_DATA, 0, 0, 3);
                handler.removeMessages(0);
                message = handler.obtainMessage();
                message.what = 0;
                message.arg1 = (int) paramsFloatLogo.x;
                message.arg2 = (int) paramsFloatLogo.y;
                handler.sendMessageDelayed(message, MENU_STAY_TIME);
            }
        });

        sb_kb_float_quick_mouse_factor_val.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (progress < 1)
                    progress = 1;
                else if (progress > 200)
                    progress = 200;
                tv_kb_float_quick_mouse_factor_val.setText(String.valueOf(progress)+"%");
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_MOUSE_FACTOR, seekBar.getProgress(), sb_kb_float_quick_mouse_factor_ver_val.getProgress(), 3);
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SAVE_DATA, 0, 0, 3);
                handler.removeMessages(0);
                message = handler.obtainMessage();
                message.what = 0;
                message.arg1 = (int) paramsFloatLogo.x;
                message.arg2 = (int) paramsFloatLogo.y;
                handler.sendMessageDelayed(message, MENU_STAY_TIME);
            }
        });

        sb_kb_float_quick_mouse_factor_ver_val.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (progress < 1)
                    progress = 1;
                else if (progress > 200)
                    progress = 200;
                tv_kb_float_quick_mouse_factor_ver_val.setText(String.valueOf(progress)+"%");
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_MOUSE_FACTOR, sb_kb_float_quick_mouse_factor_val.getProgress(), seekBar.getProgress(), 3);
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SAVE_DATA, 0, 0, 3);
                handler.removeMessages(0);
                message = handler.obtainMessage();
                message.what = 0;
                message.arg1 = (int) paramsFloatLogo.x;
                message.arg2 = (int) paramsFloatLogo.y;
                handler.sendMessageDelayed(message, MENU_STAY_TIME);
            }
        });


        rb_kb_float_quick_setting_office.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x01, 0x01, 3);
                handler.removeMessages(0);
                message = handler.obtainMessage();
                message.what = 0;
                message.arg1 = (int) paramsFloatLogo.x;
                message.arg2 = (int) paramsFloatLogo.y;
                handler.sendMessageDelayed(message, MENU_STAY_TIME);
            }
        });
        rb_kb_float_quick_setting_game.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x00, 0x01, 3);
                handler.removeMessages(0);
                message = handler.obtainMessage();
                message.what = 0;
                message.arg1 = (int) paramsFloatLogo.x;
                message.arg2 = (int) paramsFloatLogo.y;
                handler.sendMessageDelayed(message, MENU_STAY_TIME);
            }
        });

        cb_kb_float_quick_setting_audio.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    //if(audioManager.getMode()!=AudioManager.STREAM_VOICE_CALL)
                    {
                        audioManager.setSpeakerphoneOn(false);
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
                            audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
                        else
                            audioManager.setMode(AudioManager.MODE_IN_CALL);
                    }
                    //Toast.makeText(FloatMenuService_New.this,"HeadSet",Toast.LENGTH_SHORT).show();
                    if (Transfer_Con.ENABLE_POLLING_AUDIO_TO_HEADSET) {
                        handlerAudio.removeMessages(0);
                        messageAudio = handlerAudio.obtainMessage();
                        messageAudio.what = 0;
                        messageAudio.arg1 = 1;
                        messageAudio.arg2 = 2;
                        handlerAudio.sendMessageDelayed(messageAudio, 2000);//MENU_STAY_TIME);
                    }
                } else {
                    //setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);//控制声音的大小
                    audioManager.setMode(AudioManager.MODE_NORMAL);
                    //Toast.makeText(FloatMenuService_New.this,"Default",Toast.LENGTH_SHORT).show();
                    if (Transfer_Con.ENABLE_POLLING_AUDIO_TO_HEADSET) {
                        handlerAudio.removeMessages(0);
                    }
                }
            }
        });

        btn_get_status.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(FloatMenuService_New.this, String.valueOf(audioManager.getMode()) + " ----- " + String.valueOf(audioManager.isSpeakerphoneOn()), Toast.LENGTH_SHORT).show();
            }
        });

        fmsnBroadcastReceive = new FMSN_BroadcastReceive();
//注册广播接收,注意：要监听这个系统广播就必须用这种方式来注册，不能再xml中注册，否则不能生效
        IntentFilter filter = new IntentFilter();
        filter.addAction("android.intent.action.CONFIGURATION_CHANGED");
        filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
        filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
        filter.addAction("com.opd.soeghtool.content");
        filter.addAction("com.opd.soeghtool.floatview");
        filter.addAction("android.intent.action.HEADSET_PLUG");
        registerReceiver(fmsnBroadcastReceive, filter);

        handler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                if ((!bIsHalfShow) && (!bIsPositionDataShow)) {
                    float_Logo_Layout.scrollBy(0, floatLogoSize / 2);
                    windowManager.updateViewLayout(float_Logo_Layout, paramsFloatLogo);
                    bIsHalfShow = true;
                    if (bIsFloatMenuShow) {
                        windowManager.removeView(float_menu_layout);
                        bIsFloatMenuShow = false;
                    }
                    if (bIsQuickSettingShow) {
                        windowManager.removeView(kb_Quick_Setting_Layout);
                        bIsQuickSettingShow = false;
                    }
                    if (bIsPositionDataShow) {
                        bIsPositionDataShow = false;
                        windowManager.removeView(kb_position_data_layout);
                    }
                }
            }
        };

        if (Transfer_Con.ENABLE_OPPO_MSG_HANDLE) {
            if (android.os.Build.BRAND.equalsIgnoreCase("OPPO")) {
                handlerSystem = new Handler() {
                    @Override
                    public void handleMessage(Message msg) {
                        super.handleMessage(msg);

                        Configuration mConfiguration = FloatMenuService_New.this.getResources().getConfiguration(); //获取设置的配置信息
                        if (g_prvOrientation != mConfiguration.orientation) {
                            g_prvOrientation = mConfiguration.orientation;
                            if (Configuration.ORIENTATION_PORTRAIT == mConfiguration.orientation) {
                                hideWin();
                                Log.d(TAG, "ORIENTATION_PORTRAIT");
                            } else {
                                showWin();
                                Log.d(TAG, "ORIENTATION_LANDSCAPE");
                            }
                        }

                        if (mGlobalVar.isUSBDeviceListEmpty()) {
                            Log.d(TAG, "USB Disconnect");
                            if (mGlobalVar.getbIsUsbConnect()) {
                                mGlobalVar.setbIsUsbConnect(false);
                                mGlobalVar.setbIsTransferMode(false);
                                mGlobalVar.myUsbDevice = null;
                                mGlobalVar.myInterface = null;
                                mGlobalVar.epOut = null;
                                mGlobalVar.epIn = null;
                                stopSelf();
                            }
                        }
                        message2 = handlerSystem.obtainMessage();
                        message2.what = 0;
                        message2.arg1 = 1;
                        message2.arg2 = 2;
                        handlerSystem.sendMessageDelayed(message2, 5000);//MENU_STAY_TIME);
                    }
                };
            }
        }
        message = handler.obtainMessage();
        message.what = 0;
        message.arg1 = (int) paramsFloatMenu.x;
        message.arg2 = (int) paramsFloatMenu.y;
        handler.sendMessageDelayed(message, MENU_STAY_TIME);//MENU_STAY_TIME);

        if (Transfer_Con.ENABLE_OPPO_MSG_HANDLE) {
            if (android.os.Build.BRAND.equalsIgnoreCase("OPPO")) {
                message2 = handlerSystem.obtainMessage();
                message2.what = 0;
                message2.arg1 = 1;
                message2.arg2 = 2;
                handlerSystem.sendMessageDelayed(message2, 5000);//MENU_STAY_TIME);
            }
        }

        if (Transfer_Con.ENABLE_OPPO_FOREGROUND_SERVICE) {
            if (android.os.Build.BRAND.equalsIgnoreCase("OPPO")) {
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
                    createNotificationChannel();
                }
            }
        }
        if (Transfer_Con.ENABLE_DEVICE_STATUS_POLLING) {
            if (mGlobalVar.getIsSupportShotHelpPosture_KB()) {
                handlerStatus = new Handler() {
                    @Override
                    public void handleMessage(Message msg) {
                        if (mGlobalVar.tranGet_Value_status(Transfer_Con.HID_CMD_GET_STATUS, 0, 0, u8DataBuffer)) {
                            boolean flag = bIsGunHelpOn;
                            boolean flag1 = bIsGunHelpQuickOn;
                            int index = mShotHelpIndex;
                            int gunIndex = mGunPositionIndex;
                            int posture = mShotHelpPosture;

                            if ((u8DataBuffer[0] == 0x55) && (u8DataBuffer[1] == (byte) 0xAA) && (u8DataBuffer[2] == 0x55) && (u8DataBuffer[3] == (byte) 0xAA)) {
                                if ((u8DataBuffer[16] &0x01)== 1) {
                                    flag = true;
                                }
                                else
                                    flag = false;

                                if((u8DataBuffer[16] &0x02)== 2)
                                {
                                    flag1 = true;
                                }
                                else
                                {
                                    flag1 = false;
                                }

                                index = u8DataBuffer[17];
                                posture = u8DataBuffer[18];

                                gunIndex = u8DataBuffer[25];
                            }

                            if ((flag != bIsGunHelpOn) || (flag1 != bIsGunHelpQuickOn) || (index != mShotHelpIndex) || (posture != mShotHelpPosture)|| (gunIndex != mGunPositionIndex)) {
                                bIsGunHelpOn = flag;
                                bIsGunHelpQuickOn = flag1;
                                mShotHelpIndex = index;
                                mShotHelpPosture = posture;
                                mGunPositionIndex = gunIndex;
                                if (bIsGunHelpOn) {
                                    iv_float_layout.setImageResource(R.drawable.shot_help_on);
                                } else {
                                    iv_float_layout.setImageResource(R.drawable.round_background);
                                }
                                if(bIsGunHelpQuickOn)
                                {
                                    iv_float_status_layout_switch.setImageResource(R.drawable.gunsight_on);
                                }
                                else
                                {
                                    iv_float_status_layout_switch.setImageResource(R.drawable.gunsight_off);
                                }

                                switch (mShotHelpIndex) {
                                    case 0:
                                        if(mGlobalVar.getIsSupportShptHelpInsert_KB()) {
                                            if (mGunPositionIndex == 0)
                                                iv_float_status_layout_index.setImageResource(R.drawable.num_1to1);
                                            else
                                                iv_float_status_layout_index.setImageResource(R.drawable.num_1to2);
                                        }
                                        else
                                        {
                                            iv_float_status_layout_index.setImageResource(R.drawable.num_1);
                                        }
                                        break;
                                    case 1:
                                        if(mGlobalVar.getIsSupportShptHelpInsert_KB()) {
                                            if (mGunPositionIndex == 0)
                                                iv_float_status_layout_index.setImageResource(R.drawable.num_2to1);
                                            else
                                                iv_float_status_layout_index.setImageResource(R.drawable.num_2to2);
                                        }
                                        else
                                        {
                                            iv_float_status_layout_index.setImageResource(R.drawable.num_2);
                                        }
                                        break;
                                    case 2:
                                        if(mGlobalVar.getIsSupportShptHelpInsert_KB()) {
                                            if (mGunPositionIndex == 0)
                                                iv_float_status_layout_index.setImageResource(R.drawable.num_3to1);
                                            else
                                                iv_float_status_layout_index.setImageResource(R.drawable.num_3to2);
                                        }
                                        else
                                        {
                                            iv_float_status_layout_index.setImageResource(R.drawable.num_3);
                                        }
                                        break;
                                    case 3:
                                        if(mGlobalVar.getIsSupportShptHelpInsert_KB()) {
                                            if (mGunPositionIndex == 0)
                                                iv_float_status_layout_index.setImageResource(R.drawable.num_4to1);
                                            else
                                                iv_float_status_layout_index.setImageResource(R.drawable.num_4to2);
                                        }
                                        else
                                        {
                                            iv_float_status_layout_index.setImageResource(R.drawable.num_4);
                                        }
                                        break;
                                    case 4:
                                        if(mGunPositionIndex==0)
                                            iv_float_status_layout_index.setImageResource(R.drawable.num_5to1);
                                        else
                                            iv_float_status_layout_index.setImageResource(R.drawable.num_5to2);
                                        break;
                                    default:
                                        break;
                                }

                                if (mShotHelpPosture >= 100) {
                                    iv_float_status_layout_posture.setImageResource(R.drawable.standing);
                                } else if (mShotHelpPosture >= 70) {
                                    iv_float_status_layout_posture.setImageResource(R.drawable.crouch);
                                } else if (mShotHelpPosture >= 45) {
                                    iv_float_status_layout_posture.setImageResource(R.drawable.lie_down);
                                }

                                if (u8DataBuffer[19] == 1) {
                                    iv_float_status_layout_screen.setImageResource(R.drawable.status_tv);
                                } else {
                                    iv_float_status_layout_screen.setImageResource(R.drawable.status_phone);
                                }
                                //Toast.makeText(FloatMenuService_New.this, "压枪功能:" + (bIsGunHelpOn ? "开" : "关") + String.format("  使用第%d组参数，姿势%02d%%", mShotHelpIndex + 1,mShotHelpPosture)+"", Toast.LENGTH_SHORT).show();
                                if (!bIsFloatStatusShow) {
                                    windowManager.addView(float_status_layout, paramsFloatStatus);
                                    bIsFloatStatusShow = true;
                                }
                                mStatusTimeOutCounter = 0;
                            }
                            /*
                            if (mGlobalVar.getIsAutoSwitchToHDMI()) {
                                if (bIsVirtualMouseShow) {
                                    if (mOutPutPollingCounter > (2000 / mGlobalVar.getVirtualMouseInterval())) {
                                        if (bIsAutoModeHDMIOut && (u8DataBuffer[19] != 1)) {
                                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HDMI_RESOLUTION, HDMI_Width, HDMI_Height, 3);
                                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x04, 0x04, 3);
                                        } else if ((!bIsAutoModeHDMIOut) && (u8DataBuffer[19] == 1)) {
                                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x00, 0x04, 3);
                                        }
                                        mOutPutPollingCounter = 0;
                                    }
                                } else {
                                    if (mOutPutPollingCounter > 1) {
                                        if (bIsAutoModeHDMIOut && (u8DataBuffer[19] != 1)) {
                                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HDMI_RESOLUTION, HDMI_Width, HDMI_Height, 3);
                                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x04, 0x04, 3);
                                        } else if ((!bIsAutoModeHDMIOut) && (u8DataBuffer[19] == 1)) {
                                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x00, 0x04, 3);
                                        }
                                        mOutPutPollingCounter = 0;
                                    }
                                }
                                mOutPutPollingCounter++;
                            }
                            */
                            {
                                if (u8DataBuffer[20] == 1) {
                                    if (!bIsVirtualMouseShow) {
                                        windowManager.addView(virtual_mouse_layout, paramsVirtualMouse);
                                        //Toast.makeText(FloatMenuService_New.this, "Mouse on", Toast.LENGTH_SHORT).show();
                                        bIsVirtualMouseShow = true;
                                    }
                                } else {
                                    if (bIsVirtualMouseShow) {
                                        iv_kb_virtual_mouse_arrow.setVisibility(View.GONE);
                                        windowManager.removeView(virtual_mouse_layout);
                                        //Toast.makeText(FloatMenuService_New.this, "Mouse off", Toast.LENGTH_SHORT).show();
                                        bIsVirtualMouseShow = false;
                                    }
                                }
                                if (bIsVirtualMouseShow) {
                                    int x = (u8DataBuffer[21] & 0xff) + ((u8DataBuffer[22] & 0xff) << 8);
                                    int y = (u8DataBuffer[23] & 0xff) + ((u8DataBuffer[24] & 0xff) << 8);
                                    if ((x & 0x8000) == 0x8000)   //
                                    {
                                        x = -(~(x - 1) & 0xFFFF);
                                    }
                                    if ((y & 0x8000) == 0x8000)   //
                                    {
                                        y = -(~(y - 1) & 0xFFFF);
                                    }
                                    x = panelWidth / 2 + x;
                                    y = panelHeight / 2 + y;

                                    if ((xxxx != x) || (yyyy != y)) {
                                        iv_kb_virtual_mouse_arrow.setVisibility(View.GONE);
                                        iv_kb_virtual_mouse_arrow.setX(x);
                                        iv_kb_virtual_mouse_arrow.setY(y);
                                        iv_kb_virtual_mouse_arrow.setVisibility(View.VISIBLE);
                                        //Toast.makeText(FloatMenuService_New.this, String.format("x=%d, y=%d", x, y), Toast.LENGTH_SHORT).show();
                                        xxxx = x;
                                        yyyy = y;
                                    }
                                }
                            }
                            //Log.d(TAG,String.format("------------------------------------->%x,%x,%x,%x,%x,%x",u8DataBuffer[0],u8DataBuffer[1],u8DataBuffer[2],u8DataBuffer[3],u8DataBuffer[16],u8DataBuffer[17]));
                        }
                        if(false) {
                            if (bIsFloatStatusShow) {
                                if (bIsVirtualMouseShow) {
                                    if (mStatusTimeOutCounter > (5000 / mGlobalVar.getVirtualMouseInterval())) {
                                        windowManager.removeView(float_status_layout);
                                        bIsFloatStatusShow = false;
                                    }
                                } else {
                                    if (mStatusTimeOutCounter > 25) {
                                        windowManager.removeView(float_status_layout);
                                        bIsFloatStatusShow = false;
                                    }
                                }
                                mStatusTimeOutCounter++;
                            }
                        }
                        super.handleMessage(msg);
                        messageStatus = handlerStatus.obtainMessage();
                        messageStatus.what = 0;
                        messageStatus.arg1 = 1;
                        messageStatus.arg2 = 2;
                        if (bIsVirtualMouseShow)
                            handlerStatus.sendMessageDelayed(messageStatus, 10);//mGlobalVar.getVirtualMouseInterval());//MENU_STAY_TIME);
                        else
                            handlerStatus.sendMessageDelayed(messageStatus, 200);//MENU_STAY_TIME);

                    }

                    ;
                };
                if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
                    if (mGlobalVar.getIsUseVirtualMouse())
                        mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_GAME_MODE, 0xA55AB44B, 1, 10);
                }
                messageStatus = handlerStatus.obtainMessage();
                messageStatus.what = 0;
                messageStatus.arg1 = 1;
                messageStatus.arg2 = 2;
                handlerStatus.sendMessageDelayed(messageStatus, 1000);//MENU_STAY_TIME);
            }
        }
        if (Transfer_Con.ENABLE_POLLING_AUDIO_TO_HEADSET) {
            handlerAudio = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    if (Transfer_Con.ENABLE_NEW_USER_INTERFACE) {
                        if (mGlobalVar.getIsAudioOut()) {
                            if (bIsHeadSetPlugIn) {
                                int mode = audioManager.getMode();
                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                                    audioManager.setSpeakerphoneOn(false);
                                    if (mode != AudioManager.MODE_IN_COMMUNICATION) {
                                        audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
                                        //Toast.makeText(FloatMenuService_New.this, "耳机已插入1", Toast.LENGTH_SHORT).show();
                                    }
                                } else {
                                    if (mode != AudioManager.MODE_IN_CALL) {
                                        audioManager.setMode(AudioManager.MODE_IN_CALL);
                                        //Toast.makeText(FloatMenuService_New.this, "耳机已插入2", Toast.LENGTH_SHORT).show();
                                    }
                                }
                            }
                            messageAudio = handlerAudio.obtainMessage();
                            messageAudio.what = 0;
                            messageAudio.arg1 = 1;
                            messageAudio.arg2 = 2;
                            handlerAudio.sendMessageDelayed(messageAudio, 2000);//MENU_STAY_TIME);
                        }
                    } else {
                        if (cb_kb_float_quick_setting_audio.isChecked()) {
                            int mode = audioManager.getMode();
                        /*
                        if(mode==AudioManager.STREAM_RING)
                        {
                            audioManager.setMode(AudioManager.STREAM_VOICE_CALL);
                            Toast.makeText(FloatMenuService_New.this,String.valueOf(audioManager.getMode())+" 1111----- "+String.valueOf(audioManager.isSpeakerphoneOn()),Toast.LENGTH_SHORT).show();

                        }
                        else if(mode==AudioManager.STREAM_VOICE_CALL)
                        {
                            audioManager.setSpeakerphoneOn(false);
                        }
                        else if((mode!=AudioManager.STREAM_MUSIC))
                        {
                            audioManager.setSpeakerphoneOn(false);
                            audioManager.setMode(AudioManager.STREAM_MUSIC);
                        }
                        */
                            if (mode != AudioManager.MODE_IN_CALL) {
                                audioManager.setSpeakerphoneOn(false);
                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
                                    audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
                                else
                                    audioManager.setMode(AudioManager.MODE_IN_CALL);
                            }

                            messageAudio = handlerAudio.obtainMessage();
                            messageAudio.what = 0;
                            messageAudio.arg1 = 1;
                            messageAudio.arg2 = 2;
                            handlerAudio.sendMessageDelayed(messageAudio, 2000);//MENU_STAY_TIME);
                        }
                    }
                }
            };
            if (Transfer_Con.ENABLE_NEW_USER_INTERFACE) {
                if (mGlobalVar.getIsAudioOut()) {
                    messageAudio = handlerAudio.obtainMessage();
                    messageAudio.what = 0;
                    messageAudio.arg1 = 1;
                    messageAudio.arg2 = 2;
                    handlerAudio.sendMessageDelayed(messageAudio, 2000);//MENU_STAY_TIME);
                }
            }
        }
    }

    private static final String CHANNEL_ID = "com.opd.soeghtool";

    @RequiresApi(api = Build.VERSION_CODES.O)
    private void createNotificationChannel() {
        //设定的通知渠道名称
        String channelName = getString(R.string.app_name);
        //设置通知的重要程度
        int importance = NotificationManager.IMPORTANCE_LOW;
        //构建通知渠道
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID, channelName, importance);
        channel.setDescription("手易悬浮窗正在运行");
        //在创建的通知渠道上发送通知
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID);
        builder.setSmallIcon(R.drawable.round_background) //设置通知图标
                .setContentTitle("手易")//设置通知标题
                .setContentText("手易悬浮窗正在运行")//设置通知内容
                .setAutoCancel(true) //用户触摸时，自动关闭
                .setOngoing(true);//设置处于运行状态
        //向系统注册通知渠道，注册后不能改变重要性以及其他通知行为
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.createNotificationChannel(channel);
        //将服务置于启动状态 NOTIFICATION_ID指的是创建的通知的ID
        startForeground(112, builder.build());
    }

    int selectIndex = 0;
    ImageView[] iv_func;

    public int getItemID(List<Map<String, Object>> data_list, int pos) {
        return (int) data_list.get(pos).get("id");
    }

    boolean getIsUseEvTabl(int ev) {
        if ((ev == Transfer_Con.bFPSPullGunDown) || (ev == Transfer_Con.ATTR_MULTI_POSITION)
                || (ev == Transfer_Con.ATTR_MACRO_ADV) || (ev == Transfer_Con.ATTR_MACRO)) {
            return true;
        }
        return false;
    }

    void reassignedAttrEvTable() {
        int[] u8Temp = new int[Transfer_Con.MAX_AUTOEVENT_LENGTH_KB];
        int u16StartAddr = 0;
        Log.d(TAG, "reassignedAttrEvTable");
        for (int a = 0; a < Transfer_Con.MAX_COORDINATE; a++) {
            if (getIsUseEvTabl(tempAttrTbl[a][0])) // 非无效
            {
                Log.d(TAG, "move");
                //转移到暂存队列
                System.arraycopy(tempAttrEvTbl, (tempAttrTbl[a][1]), u8Temp, u16StartAddr, tempAttrTbl[a][2]);
                //改变起始地址
                tempAttrTbl[a][1] = u16StartAddr;
                //下一个开始地址
                u16StartAddr += tempAttrTbl[a][2];
            }
        }
        // 存放回数组
        System.arraycopy(u8Temp, 0, tempAttrEvTbl, 0, u16StartAddr);
        //改变长度
        g_mAutoEventTblUsed = u16StartAddr;
    }

    public void submit_tempAttrEvTable(int index) {
        if (getIsUseEvTabl(tempAttrTbl[index][0])) {
            if ((tempAttrTbl[index][2]) >= g_mAutoEventTblLen) {   // 原有空间 大于等于 现在空间
                tempAttrTbl[index][0] = tempAttrTblEdit[0];
                tempAttrTbl[index][2] = g_mAutoEventTblLen;
                System.arraycopy(tempAttrEvTblEdit, 0, tempAttrEvTbl, (tempAttrTbl[index][1]), g_mAutoEventTblLen);
            } else {
                tempAttrTbl[index][0] = 0;
                reassignedAttrEvTable();
                if ((g_mAutoEventTblLen) + (g_mAutoEventTblUsed) > Transfer_Con.MAX_AUTOEVENT_LENGTH_KB) {
                    Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_button_setting_advance_total_event_buffer), Toast.LENGTH_SHORT).show();
                } else {
                    tempAttrTbl[index][0] = tempAttrTblEdit[0];
                    tempAttrTbl[index][1] = g_mAutoEventTblUsed;
                    tempAttrTbl[index][2] = g_mAutoEventTblLen;
                    System.arraycopy(tempAttrEvTblEdit, 0, tempAttrEvTbl, g_mAutoEventTblUsed, g_mAutoEventTblLen);
                    g_mAutoEventTblUsed = g_mAutoEventTblUsed + g_mAutoEventTblLen;
                }
            }
        } else {
            reassignedAttrEvTable();
            if ((g_mAutoEventTblUsed + g_mAutoEventTblLen) > Transfer_Con.MAX_AUTOEVENT_LENGTH_KB) {
                Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_button_setting_advance_total_event_buffer), Toast.LENGTH_SHORT).show();
                return;
            }
            tempAttrTbl[index][0] = tempAttrTblEdit[0];
            tempAttrTbl[index][1] = g_mAutoEventTblUsed;
            tempAttrTbl[index][2] = g_mAutoEventTblLen;
            System.arraycopy(tempAttrEvTblEdit, 0, tempAttrEvTbl, g_mAutoEventTblUsed, g_mAutoEventTblLen);
            g_mAutoEventTblUsed = g_mAutoEventTblUsed + g_mAutoEventTblLen;
        }

        /*
        for(int a=0;a<Transfer_Con.MAX_COORDINATE;a++)
        Log.d(TAG,String.format("i=%d,%x,%d,%d",a,tempAttrTbl[a][0],tempAttrTbl[a][1],tempAttrTbl[a][2]));

        String str="";
        for(int a=0;a<Transfer_Con.MAX_AUTOEVENT_LENGTH_KB;a++)
        {

            str+=String.valueOf(tempAttrEvTbl[a])+", ";
        }
        Log.d(TAG,"----------------------->>>>>>>>>>>>>>>>>>>>"+str);
        */
    }

    public void showKBAdvanceSetting() {
        AlertDialog.Builder builder = new AlertDialog.Builder(FloatMenuService_New.this);
        //EditText input = new EditText(ButtonSettingService.this);
        View view = LayoutInflater.from(FloatMenuService_New.this).inflate(R.layout.kb_function_select_layout, null, false);
        GridView gv_kb_function_select = view.findViewById(R.id.gv_kb_function_select);
        SeekBar sb_kb_function_mouse_sense = view.findViewById(R.id.sb_kb_function_mouse_sense);
        final TextView tv_kb_function_mouse_sense_val = view.findViewById(R.id.tv_kb_function_mouse_sense_val);
        sb_kb_function_mouse_sense.setMax(50);

        RelativeLayout layout_kb_function_rocker_range = view.findViewById(R.id.layout_kb_function_rocker_range);
        SeekBar sb_kb_function_rocker_range = view.findViewById(R.id.sb_kb_function_rocker_range);
        final TextView tv_kb_function_rocker_range_val = view.findViewById(R.id.tv_kb_function_rocker_range_val);
        //sb_kb_function_mouse_sense.setMin(1);
        if (mGlobalVar.tranGet_Value_retry(Transfer_Con.HID_CMD_GET_R_ROCK_MIN, 0, 0, u8DataBuffer, 5)) {
            sb_kb_function_mouse_sense.setProgress(u8DataBuffer[0]);
            tv_kb_function_mouse_sense_val.setText(String.valueOf(u8DataBuffer[0]));
        }
        if (mGlobalVar.getIsSupportMultiShotHelp_KB()) {
            layout_kb_function_rocker_range.setVisibility(View.VISIBLE);
            sb_kb_function_rocker_range.setProgress(mGlobalVar.getRockerMoveRange_KB());
            tv_kb_function_rocker_range_val.setText(String.format("%d%%", mGlobalVar.getRockerMoveRange_KB()));
        }

        if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
            if (bIsVirtualMouseShow) {
                windowManager.removeView(virtual_mouse_layout);
                bIsVirtualMouseShow = false;
                bIsVirtualMouseShowBackup = true;
            } else {
                bIsVirtualMouseShowBackup = false;
            }
        }

        final LinearLayout gv_kb_function_select_right_layout = view.findViewById(R.id.gv_kb_function_select_right_layout);
        final List<Map<String, Object>> data_list;
        SimpleAdapter sim_adapter;

                    /*
                    ImageView iv_f = view.findViewById(R.id.iv_kb_function_select_forward);
                    ImageView iv_b = view.findViewById(R.id.iv_kb_function_select_backward);
                    ImageView iv_a = view.findViewById(R.id.iv_kb_function_select_left);
                    ImageView iv_d = view.findViewById(R.id.iv_kb_function_select_right);
                    ImageView iv_view = view.findViewById(R.id.iv_kb_function_select_view);

                    TypedArray ar = getResources().obtainTypedArray(R.array.mp1_button_images);
                    int len = ar.length();
                    int[] resIds = new int[len];
                    resIds[mGlobalVar.kbTbl[0]&0xFF] = ar.getResourceId(mGlobalVar.kbTbl[0]&0xFF, 0);
                    iv_f.setImageResource(resIds[mGlobalVar.kbTbl[0]&0xFF]);
                    resIds[mGlobalVar.kbTbl[1]&0xFF] = ar.getResourceId(mGlobalVar.kbTbl[1]&0xFF, 0);
                    iv_b.setImageResource(resIds[mGlobalVar.kbTbl[1]&0xFF]);
                    resIds[mGlobalVar.kbTbl[2]&0xFF] = ar.getResourceId(mGlobalVar.kbTbl[2]&0xFF, 0);
                    iv_a.setImageResource(resIds[mGlobalVar.kbTbl[2]&0xFF]);
                    resIds[mGlobalVar.kbTbl[3]&0xFF] = ar.getResourceId(mGlobalVar.kbTbl[3]&0xFF, 0);
                    iv_d.setImageResource(resIds[mGlobalVar.kbTbl[3]&0xFF]);
                    resIds[mGlobalVar.kbTbl[4]&0xFF] = ar.getResourceId(mGlobalVar.kbTbl[4]&0xFF, 0);
                    iv_view.setImageResource(resIds[mGlobalVar.kbTbl[4]&0xFF]);
                    */
        data_list = new ArrayList<Map<String, Object>>();
        iv_func = new ImageView[5];
        TypedArray ar = getResources().obtainTypedArray(R.array.mp1_button_images);
        int len = ar.length();
        int[] resIds = new int[len];

        for (int a = 4; a < mGlobalVar.getDirectCenterIndex(); a++) {
            if ((a > 0x63) && (a < 0x80))
                continue;
            else if(mGlobalVar.switchMouseToKeyEvent((mGlobalVar.getSwitchToMouseKey_KB()&0xff00)>>8,mGlobalVar.getSwitchToMouseKey_KB()&0xff)==a)
                continue;
            if (mGlobalVar.getIsSupportMultiShotHelp_KB()) {
                if ((a >= 0x3A) && (a <= 0x3E)) {
                    continue;
                }
            }
            Map<String, Object> map = new HashMap<String, Object>();
            resIds[a] = ar.getResourceId(a, 0);
            map.put("image", resIds[a]);
            map.put("id", a);
            data_list.add(map);
        }


        String[] from = {"image"};
        int[] to = {R.id.iv_kb_gv};
        sim_adapter = new SimpleAdapter(FloatMenuService_New.this, data_list, R.layout.kb_function_select_gv_content, from, to);
        gv_kb_function_select.setAdapter(sim_adapter);
        gv_kb_function_select.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                gv_kb_function_select_right_layout.setVisibility(View.GONE);
                tempKbTbl[selectIndex] = (byte) getItemID(data_list, position);
                TypedArray ar = getResources().obtainTypedArray(R.array.mp1_button_images);
                int len = ar.length();
                int[] resIds = new int[len];
                resIds[tempKbTbl[selectIndex] & 0xFF] = ar.getResourceId(tempKbTbl[selectIndex] & 0xFF, 0);
                iv_func[selectIndex].setImageResource(resIds[tempKbTbl[selectIndex] & 0xFF]);
                ar.recycle();
            }
        });


        iv_func[0] = view.findViewById(R.id.iv_kb_function_select_forward);
        iv_func[1] = view.findViewById(R.id.iv_kb_function_select_backward);
        iv_func[2] = view.findViewById(R.id.iv_kb_function_select_left);
        iv_func[3] = view.findViewById(R.id.iv_kb_function_select_right);
        iv_func[4] = view.findViewById(R.id.iv_kb_function_select_view);
        for (int a = 0; a < 4; a++) {
            final int index = a;
            resIds[tempKbTbl[a] & 0xFF] = ar.getResourceId(tempKbTbl[a] & 0xFF, 0);
            iv_func[a].setImageResource(resIds[tempKbTbl[a] & 0xFF]);
            iv_func[a].setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    gv_kb_function_select_right_layout.setVisibility(View.VISIBLE);
                    selectIndex = index;
                }
            });
        }

        ar.recycle();

        builder.setView(view);
        builder.setTitle("特殊功能设置")
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        tempAttrTbl[mGlobalVar.kbTbl[0] & 0xFF][0] = 0xFF;
                        tempAttrTbl[mGlobalVar.kbTbl[1] & 0xFF][0] = 0xFF;
                        tempAttrTbl[mGlobalVar.kbTbl[2] & 0xFF][0] = 0xFF;
                        tempAttrTbl[mGlobalVar.kbTbl[3] & 0xFF][0] = 0xFF;
                        tempAttrTbl[mGlobalVar.kbTbl[4] & 0xFF][0] = 0xFF;

                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[0]] = 0x8000;
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[0] + 1] = 0x8000;
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[1]] = 0x8000;
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[1] + 1] = 0x8000;
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[2]] = 0x8000;
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[2] + 1] = 0x8000;
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[3]] = 0x8000;
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[3] + 1] = 0x8000;

                        mGlobalVar.kbTbl = tempKbTbl.clone();
                        bIsChanged = true;
                        tempAttrTbl[mGlobalVar.kbTbl[0] & 0xFF][0] = 0x20;
                        tempAttrTbl[mGlobalVar.kbTbl[1] & 0xFF][0] = 0x21;
                        tempAttrTbl[mGlobalVar.kbTbl[2] & 0xFF][0] = 0x22;
                        tempAttrTbl[mGlobalVar.kbTbl[3] & 0xFF][0] = 0x23;
                        tempAttrTbl[mGlobalVar.kbTbl[4] & 0xFF][0] = 0x24;

                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[0]] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()];
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[0] + 1] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1];
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[1]] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()];
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[1] + 1] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1];
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[2]] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()];
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[2] + 1] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1];
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[3]] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()];
                        tempCoordinateTbl[2 * mGlobalVar.kbTbl[3] + 1] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1];
                        showFloatImage();
                        iv_btn_setting_kb_ring.setVisibility(View.GONE);
                        g_preButtonIndex = 0;
                    }
                })
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        tempKbTbl = mGlobalVar.kbTbl.clone();
                    }
                });
        mDialog = builder.create();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (Settings.canDrawOverlays(FloatMenuService_New.this))
                mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
        } else {
            mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        }
        mDialog.setCanceledOnTouchOutside(false);
        mDialog.show();
        if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
            if (bIsVirtualMouseShowBackup) {
                windowManager.addView(virtual_mouse_layout, paramsVirtualMouse);
                bIsVirtualMouseShow = true;
            }
        }
        sb_kb_function_mouse_sense.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (progress < 1)
                    progress = 1;
                else if (progress > 50)
                    progress = 50;
                tv_kb_function_mouse_sense_val.setText(String.valueOf(progress));
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_R_ROCK_MIN, seekBar.getProgress(), 0, 3);
            }
        });

        sb_kb_function_rocker_range.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                tv_kb_function_rocker_range_val.setText(String.format("%d%%", progress));
                mGlobalVar.setRockerMoveRange_KB(progress);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                //saveUserData(false);
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_ROCKER_RANGE, seekBar.getProgress(), 0, 3);
                SharedPreferences.Editor editor = getSharedPreferences(Transfer_Con.SAVENAME, MODE_PRIVATE).edit();
                editor.putInt("RockerRange_KB", mGlobalVar.getRockerMoveRange_KB());
                editor.apply();
            }
        });
    }

    @SuppressLint("ClickableViewAccessibility")
    public void showSplitButton() {

        for (int a = 0; a < g_mButtonSplitNum; a++) {
            button_preview_notouch_layout.removeView(img_button_split[a]);
            button_pos_edit_layout.removeView(img_button_split_edit[a]);
        }

        g_mButtonSplitNum = 0;
        for (int a = 0; a < Transfer_Con.MAX_COORDINATE; a++) {
            if (tempAttrTbl[a][0] == Transfer_Con.ATTR_MULTI_POSITION) {
                g_mButtonSplitNum += tempAttrEvTbl[tempAttrTbl[a][1]];
            }
        }
        TypedArray ar;
        ar = getResources().obtainTypedArray(R.array.mp1_button_images);
        int len = ar.length();
        int[] resIds = new int[len];
        if (g_mButtonSplitNum > 0) {
            int index = 0;
            img_button_split = new ImageView[g_mButtonSplitNum];
            img_button_split_edit = new ImageView[g_mButtonSplitNum];
            for (int a = 0; a < Transfer_Con.MAX_COORDINATE; a++) {
                resIds[a] = ar.getResourceId(a, 0);
                if (tempAttrTbl[a][0] == Transfer_Con.ATTR_MULTI_POSITION) {
                    for (int k = 0; k < tempAttrEvTbl[tempAttrTbl[a][1]]; k++) {
                        int x, y;
                        //
                        img_button_split[index] = new ImageView(FloatMenuService_New.this);
                        img_button_split[index].setVisibility(View.GONE);
                        img_button_split[index].setImageResource(resIds[a]);
                        y = (tempAttrEvTbl[tempAttrTbl[a][1] + 4 * k + 1] << 8) | tempAttrEvTbl[tempAttrTbl[a][1] + 4 * k + 2];
                        x = (tempAttrEvTbl[tempAttrTbl[a][1] + 4 * k + 3] << 8) | tempAttrEvTbl[tempAttrTbl[a][1] + 4 * k + 4];
                        y = y * panelHeight / 0x7FFF;
                        x = x * panelWidth / 0x7FFF;
                        img_button_split[index].setX(x - mImageHalfSize);
                        img_button_split[index].setY(y - mImageHalfSize);
                        img_button_split[index].setTag(a + (k << 8));
                        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(mImageHalfSize * 2, mImageHalfSize * 2);
                        img_button_split[index].setAlpha(((float) mGlobalVar.getNormal_Icon_Alpha()) / 10);
                        img_button_split[index].setVisibility(View.VISIBLE);
                        button_preview_notouch_layout.addView(img_button_split[index], lp);
                        //
                        img_button_split_edit[index] = new ImageView(FloatMenuService_New.this);
                        img_button_split_edit[index].setVisibility(View.GONE);
                        img_button_split_edit[index].setImageResource(resIds[a]);
                        img_button_split_edit[index].setVisibility(View.GONE);
                        img_button_split_edit[index].setX(x - mImageHalfSizeEdit);
                        img_button_split_edit[index].setY(y - mImageHalfSizeEdit);
                        img_button_split_edit[index].setTag(a + (k << 8));
                        ViewGroup.LayoutParams lp1 = new ViewGroup.LayoutParams(mImageHalfSizeEdit * 2, mImageHalfSizeEdit * 2);
                        img_button_split_edit[index].setAlpha(((float) mGlobalVar.getPt_Tbl_View_Alpha()) / 10);
                        img_button_split_edit[index].setVisibility(View.VISIBLE);
                        button_pos_edit_layout.addView(img_button_split_edit[index], lp1);

                        img_button_split_edit[index].setOnTouchListener(new View.OnTouchListener() {

                            long[] hints = new long[2];
                            int prevX = 0, prevY = 0;

                            @Override
                            public boolean onTouch(View v, MotionEvent event) {
                                int pos_x, pos_y;
                                boolean bIsLongPress = false;
                                boolean bIsChange = false;
                                switch (event.getAction()) {
                                    case MotionEvent.ACTION_DOWN:
                                        System.arraycopy(hints, 1, hints, 0, hints.length - 1);
                                        hints[hints.length - 1] = SystemClock.uptimeMillis();
                                        prevX = (int) event.getRawX();
                                        prevY = (int) event.getRawY();
                                        iv_btn_setting_kb_ring.setVisibility(View.GONE);
                                        iv_btn_setting_kb_ring_split.setVisibility(View.GONE);
                                        iv_btn_setting_kb_ring_split.setX(v.getX() - (mImgRingSize - mImageHalfSizeEdit));
                                        iv_btn_setting_kb_ring_split.setY(v.getY() - (mImgRingSize - mImageHalfSizeEdit));
                                        iv_btn_setting_kb_ring_split.setVisibility(View.VISIBLE);
                                        break;
                                    case MotionEvent.ACTION_MOVE:
                                        if ((Math.abs(prevX - (int) event.getRawX()) > 20) || (Math.abs(prevY - (int) event.getRawY()) > 20)) {
                                            pos_x = (int) event.getRawX() - mImageHalfSizeEdit;
                                            pos_y = (int) event.getRawY() - mImageHalfSizeEdit;
                                            v.setX(pos_x);
                                            v.setY(pos_y);

                                            iv_btn_setting_kb_ring_split.setX(v.getX() - (mImgRingSize - mImageHalfSizeEdit));
                                            iv_btn_setting_kb_ring_split.setY(v.getY() - (mImgRingSize - mImageHalfSizeEdit));
                                            iv_kb_button_setting_add.setVisibility(View.GONE);
                                            iv_kb_button_setting_remove.setVisibility(View.VISIBLE);
                                            showNormalEmptyBtn(false);
                                            bIsChanged = true;
                                        }
                                        break;
                                    case MotionEvent.ACTION_UP:
                                        System.arraycopy(hints, 1, hints, 0, hints.length - 1);
                                        hints[hints.length - 1] = SystemClock.uptimeMillis();
                                        iv_kb_button_setting_remove.setVisibility(View.GONE);
                                        iv_kb_button_setting_add.setVisibility(View.VISIBLE);
                                        int tag = (int) v.getTag();
                                        int btn = tag & 0xff;
                                        tag = (tag & 0x0000ff00) >> 8;
                                        g_mAutoEventTblLen = tempAttrTbl[btn][2];
                                        System.arraycopy(tempAttrEvTbl, tempAttrTbl[btn][1], tempAttrEvTblEdit, 0, tempAttrTbl[btn][2]);

                                        if (v.getX() > iv_kb_button_setting_remove.getX() - iv_kb_button_setting_remove.getWidth() / 2 && (v.getX() < (iv_kb_button_setting_remove.getX() + iv_kb_button_setting_remove.getWidth() / 2))
                                                && v.getY() > iv_kb_button_setting_remove.getY() - iv_kb_button_setting_remove.getHeight() / 2 && (v.getY() < (iv_kb_button_setting_remove.getY() + iv_kb_button_setting_remove.getHeight() / 2))
                                        ) {

                                            if (tempAttrEvTblEdit[0] <= 1) {
                                                tempAttrTbl[btn][0] = 0;
                                                tempAttrTbl[btn][1] = 0xffff;
                                                tempAttrTbl[btn][2] = 0xffff;
                                                g_mAutoEventTblLen = 0;
                                            } else {
                                                for (int s = tag; s < (tempAttrEvTblEdit[0] - 1); s++) {
                                                    tempAttrEvTblEdit[1 + s * 4] = tempAttrEvTblEdit[1 + (s + 1) * 4];
                                                    tempAttrEvTblEdit[1 + s * 4 + 1] = tempAttrEvTblEdit[1 + (s + 1) * 4 + 1];
                                                    tempAttrEvTblEdit[1 + s * 4 + 2] = tempAttrEvTblEdit[1 + (s + 1) * 4 + 2];
                                                    tempAttrEvTblEdit[1 + s * 4 + 3] = tempAttrEvTblEdit[1 + (s + 1) * 4 + 3];
                                                }
                                                tempAttrEvTblEdit[0]--;
                                                g_mAutoEventTblLen -= 4;
                                            }
                                            bIsChange = true;
                                            v.setVisibility(View.GONE);
                                            iv_btn_setting_kb_ring_split.setVisibility(View.GONE);
                                        } else if ((Math.abs(prevX - (int) event.getRawX()) > 20) || (Math.abs(prevY - (int) event.getRawY()) > 20)) {
                                            pos_x = ((int) event.getRawX()) * 0x7FFF / panelWidth;
                                            pos_y = ((int) event.getRawY()) * 0x7FFF / panelHeight;

                                            tempAttrEvTblEdit[1 + tag * 4] = (pos_y & 0xff00) >> 8;
                                            tempAttrEvTblEdit[1 + tag * 4 + 1] = (pos_y & 0x00ff);
                                            tempAttrEvTblEdit[1 + tag * 4 + 2] = (pos_x & 0xff00) >> 8;
                                            ;
                                            tempAttrEvTblEdit[1 + tag * 4 + 3] = (pos_x & 0x00ff);
                                            bIsChange = true;
                                            // tempCoordinateTbl[2 * k] = (pos_y ) * 0x7FFF / panelHeight;
                                            // tempCoordinateTbl[2 * k + 1] = (pos_x ) * 0x7FFF / panelWidth;
                                        }
                                        if (SystemClock.uptimeMillis() - hints[0] >= 300) {
                                            bIsLongPress = true;
                                        }

                                        if (bIsChange) {

                                            submit_tempAttrEvTable(btn);
                                            byte[] temp = new byte[tempAttrTbl[btn][2]];
                                            for (int s = 0; s < tempAttrTbl[btn][2]; s++)
                                                temp[s] = (byte) tempAttrEvTblEdit[s];
                                            for (int retry = 0; retry < 5; retry++) {
                                                if (mGlobalVar.tranSet_MultiValue(Transfer_Con.HID_CMD_SET_KEY_ATTR, tempAttrTbl[btn][1], tempAttrTbl[btn][2], temp)) {
                                                    break;
                                                }
                                            }
                                        }

                                        break;
                                }
                                return bIsLongPress;
                            }
                        });

                        img_button_split_edit[index].setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {

                            }
                        });

                        index++;
                    }
                }
            }
        }
        ar.recycle();
    }


    @SuppressLint("ClickableViewAccessibility")
    public void showFloatImage() {
        if (mGlobalVar.getbIsUsbConnect()) {
            TypedArray ar;
            ar = getResources().obtainTypedArray(R.array.mp1_button_images);
            int len = ar.length();
            int[] resIds = new int[len];
            for (int a = 0; a < mGlobalVar.getDirectCenterIndex(); a++) {
                int x = 0, y = 0;
                resIds[a] = ar.getResourceId(a, 0);
                if (!bIsImageAlreadyCreate)
                    img_button[a] = new ImageView(FloatMenuService_New.this);
                img_button[a].setVisibility(View.GONE);
                img_button[a].setImageResource(resIds[a]);

                if (tempCoordinateTbl[a * 2] > 0x7FFF)
                    tempCoordinateTbl[a * 2] = 0x7FFF;
                else if (tempCoordinateTbl[a * 2] < 0)
                    tempCoordinateTbl[a * 2] = 0;
                if (tempCoordinateTbl[a * 2 + 1] > 0x7FFF)
                    tempCoordinateTbl[a * 2 + 1] = 0x7FFF;
                else if (tempCoordinateTbl[a * 2 + 1] < 0)
                    tempCoordinateTbl[a * 2 + 1] = 0;

                y = tempCoordinateTbl[a * 2] * panelHeight / 0x7FFF;
                x = tempCoordinateTbl[a * 2 + 1] * panelWidth / 0x7FFF;
                img_button[a].setX(x - mImageHalfSize);
                img_button[a].setY(y - mImageHalfSize);
                ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(mImageHalfSize * 2, mImageHalfSize * 2);
                img_button[a].setAlpha(((float) mGlobalVar.getNormal_Icon_Alpha()) / 10);
                if ((tempAttrTbl[a][0] & 0xff) == 0xff)
                    img_button[a].setVisibility(View.GONE);
                else if (mGlobalVar.getIsSupportMultiShotHelp_KB() && ((tempAttrTbl[a][0] >= Transfer_Con.ATTR_QUICK_ONOFF) && (tempAttrTbl[a][0] <= Transfer_Con.ATTR_QUICK_SWITCH))) {
                    img_button[a].setVisibility(View.GONE);
                }else if(mGlobalVar.switchMouseToKeyEvent((mGlobalVar.getSwitchToMouseKey_KB()&0xff00)>>8,mGlobalVar.getSwitchToMouseKey_KB()&0xff)==a)
                    img_button[a].setVisibility(View.GONE);
                else
                    img_button[a].setVisibility(View.VISIBLE);

                if (!bIsImageAlreadyCreate)
                    button_preview_notouch_layout.addView(img_button[a], lp);
                else {
                    ViewGroup.LayoutParams params = img_button[a].getLayoutParams();
                    params.width = mImageHalfSize * 2;
                    params.height = mImageHalfSize * 2;
                    img_button[a].setLayoutParams(params);
                }
            }

            if (!bIsImageAlreadyCreate) {
                iv_kb_setting_direct = new ImageView(FloatMenuService_New.this);
            }
            iv_kb_setting_direct.setImageResource(R.drawable.kb_direct);
            iv_kb_setting_direct.setX((float) tempCoordinateTbl[mGlobalVar.getDirectCenterIndex() * 2 + 1] * panelWidth / 0x7FFF - mImageHalfSize * 3);
            iv_kb_setting_direct.setY((float) tempCoordinateTbl[mGlobalVar.getDirectCenterIndex() * 2] * panelHeight / 0x7FFF - mImageHalfSize * 3);
            ViewGroup.LayoutParams lp1 = new ViewGroup.LayoutParams(mImageHalfSize * 6, mImageHalfSize * 6);
            iv_kb_setting_direct.setAlpha(((float) mGlobalVar.getNormal_Icon_Alpha()) / 10);

            iv_kb_setting_direct.setVisibility(View.VISIBLE);
            if (!bIsImageAlreadyCreate) {
                button_preview_notouch_layout.addView(iv_kb_setting_direct, lp1);
            } else {
                ViewGroup.LayoutParams params = iv_kb_setting_direct.getLayoutParams();
                params.width = mImageHalfSize * 6;
                params.height = mImageHalfSize * 6;
                iv_kb_setting_direct.setLayoutParams(params);
            }
            if ((tempKbTbl[0] & 0xff) != 0xff) {
                img_button[tempKbTbl[0]].setX(iv_kb_setting_direct.getX() + mImageHalfSize * 2);
                img_button[tempKbTbl[0]].setY(iv_kb_setting_direct.getY() + mImageHalfSize * 2 - mImageHalfSize * 2 + (float) mImageHalfSize / 7);
            }
            if ((tempKbTbl[1] & 0xff) != 0xff) {
                img_button[tempKbTbl[1]].setX(iv_kb_setting_direct.getX() + mImageHalfSize * 2);
                img_button[tempKbTbl[1]].setY(iv_kb_setting_direct.getY() + mImageHalfSize * 2 + mImageHalfSize * 2 - (float) mImageHalfSize / 7);
            }
            if ((tempKbTbl[2] & 0xff) != 0xff) {
                img_button[tempKbTbl[2]].setX(iv_kb_setting_direct.getX() + mImageHalfSize * 2 - mImageHalfSize * 2 + (float) mImageHalfSize / 7);
                img_button[tempKbTbl[2]].setY(iv_kb_setting_direct.getY() + mImageHalfSize * 2);
            }
            if ((tempKbTbl[3] & 0xff) != 0xff) {
                img_button[tempKbTbl[3]].setX(iv_kb_setting_direct.getX() + mImageHalfSize * 2 + mImageHalfSize * 2 - (float) mImageHalfSize / 7);
                img_button[tempKbTbl[3]].setY(iv_kb_setting_direct.getY() + mImageHalfSize * 2);
            }

            bIsImageAlreadyCreate = true;
            ar.recycle();
        }

        if (mGlobalVar.getbIsUsbConnect()) {
            ViewGroup.LayoutParams ring_lp = iv_btn_setting_kb_ring.getLayoutParams();
            ViewGroup.LayoutParams ring_lp1 = iv_btn_setting_kb_ring_split.getLayoutParams();
            iv_btn_setting_kb_ring.setAlpha(1.0f);
            iv_btn_setting_kb_ring_split.setAlpha(1.0f);
            ring_lp.width = mImageHalfSizeEdit * 2 + mImageHalfSizeEdit / 2;
            ring_lp.height = mImageHalfSizeEdit * 2 + mImageHalfSizeEdit / 2;
            ring_lp1.width = ring_lp.width;
            ring_lp1.height = ring_lp.height;
            mImgRingSize = ring_lp.width / 2;

            TypedArray ar;
            ar = getResources().obtainTypedArray(R.array.mp1_button_images);
            int len = ar.length();
            int[] resIds = new int[len];
            for (int a = 0; a < mGlobalVar.getDirectCenterIndex(); a++) {
                int x = 0, y = 0;
                final int k = a;
                resIds[a] = ar.getResourceId(a, 0);
                if (!bIsImageAlreadyCreate1)
                    img_button_edit[a] = new ImageView(FloatMenuService_New.this);
                img_button_edit[a].setVisibility(View.GONE);
                img_button_edit[a].setImageResource(resIds[a]);

                if (tempCoordinateTbl[a * 2] > 0x7FFF)
                    tempCoordinateTbl[a * 2] = 0x7FFF;
                else if (tempCoordinateTbl[a * 2] < 0)
                    tempCoordinateTbl[a * 2] = 0;
                if (tempCoordinateTbl[a * 2 + 1] > 0x7FFF)
                    tempCoordinateTbl[a * 2 + 1] = 0x7FFF;
                else if (tempCoordinateTbl[a * 2 + 1] < 0)
                    tempCoordinateTbl[a * 2 + 1] = 0;

                y = tempCoordinateTbl[a * 2] * panelHeight / 0x7FFF;
                x = tempCoordinateTbl[a * 2 + 1] * panelWidth / 0x7FFF;
                img_button_edit[a].setX(x - mImageHalfSizeEdit);
                img_button_edit[a].setY(y - mImageHalfSizeEdit);
                ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(mImageHalfSizeEdit * 2, mImageHalfSizeEdit * 2);
                img_button_edit[a].setAlpha(((float) mGlobalVar.getPt_Tbl_View_Alpha()) / 10);
                if ((tempAttrTbl[a][0] & 0xff) == 0xff)
                    img_button_edit[a].setVisibility(View.GONE);
                else if (mGlobalVar.getIsSupportMultiShotHelp_KB() && ((tempAttrTbl[a][0] >= Transfer_Con.ATTR_QUICK_ONOFF) && (tempAttrTbl[a][0] <= Transfer_Con.ATTR_QUICK_SWITCH))) {
                    img_button_edit[a].setVisibility(View.GONE);
                } else if(mGlobalVar.switchMouseToKeyEvent((mGlobalVar.getSwitchToMouseKey_KB()&0xff00)>>8,mGlobalVar.getSwitchToMouseKey_KB()&0xff)==a)
                    img_button[a].setVisibility(View.GONE);
                else
                    img_button_edit[a].setVisibility(View.VISIBLE);
                if (!bIsImageAlreadyCreate1)
                    button_pos_edit_layout.addView(img_button_edit[a], lp);
                else {
                    ViewGroup.LayoutParams params = img_button_edit[a].getLayoutParams();
                    params.width = mImageHalfSizeEdit * 2;
                    params.height = mImageHalfSizeEdit * 2;
                    img_button_edit[a].setLayoutParams(params);
                }
                img_button_edit[a].setOnTouchListener(new View.OnTouchListener() {

                    long[] hints = new long[2];
                    int prevX = 0, prevY = 0;

                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        int pos_x, pos_y;
                        boolean bIsLongPress = false;
                        if (Transfer_Con.ENABLE_SUPPORT_MACRO) {
                            if (bIsMacro_record) {
                                return false;
                            }
                        }
                        switch (event.getAction()) {
                            case MotionEvent.ACTION_DOWN:
                                System.arraycopy(hints, 1, hints, 0, hints.length - 1);
                                hints[hints.length - 1] = SystemClock.uptimeMillis();
                                prevX = (int) event.getRawX();
                                prevY = (int) event.getRawY();
                                iv_btn_setting_kb_ring_split.setVisibility(View.GONE);
                                iv_btn_setting_kb_ring.setVisibility(View.GONE);
                                ViewGroup.LayoutParams ring_lp = iv_btn_setting_kb_ring.getLayoutParams();
                                ring_lp.width = mImgRingSize * 2;
                                ring_lp.height = mImgRingSize * 2;
                                iv_btn_setting_kb_ring.setX(v.getX() - (mImgRingSize - mImageHalfSizeEdit));
                                iv_btn_setting_kb_ring.setY(v.getY() - (mImgRingSize - mImageHalfSizeEdit));
                                iv_btn_setting_kb_ring.setVisibility(View.VISIBLE);
                                break;
                            case MotionEvent.ACTION_MOVE:
                                if ((Math.abs(prevX - (int) event.getRawX()) > 20) || (Math.abs(prevY - (int) event.getRawY()) > 20)) {
                                    pos_x = (int) event.getRawX() - mImageHalfSizeEdit;
                                    pos_y = (int) event.getRawY() - mImageHalfSizeEdit;

                                    if (pos_x < 0)
                                        pos_x = 0;
                                    else if (pos_x > panelWidth)
                                        pos_x = panelWidth;
                                    if (pos_y < 0)
                                        pos_y = 0;
                                    else if (pos_y > panelHeight)
                                        pos_y = panelHeight;
                                    v.setX(pos_x);
                                    v.setY(pos_y);


                                    tempCoordinateTbl[2 * k] = (pos_y + mImageHalfSizeEdit) * 0x7FFF / panelHeight;
                                    tempCoordinateTbl[2 * k + 1] = (pos_x + mImageHalfSizeEdit) * 0x7FFF / panelWidth;
                                    iv_btn_setting_kb_ring.setX(v.getX() - (mImgRingSize - mImageHalfSizeEdit));
                                    iv_btn_setting_kb_ring.setY(v.getY() - (mImgRingSize - mImageHalfSizeEdit));
                                    if ((tempAttrTbl[k][0] & 0xff) == 0xff) {
                                        tempAttrTbl[k][0] = 0x0000;
                                        tempAttrTbl[k][1] = 0x0000;
                                        tempAttrTbl[k][2] = 0x0000;
                                    }
                                    iv_kb_button_setting_add.setVisibility(View.GONE);
                                    iv_kb_button_setting_remove.setVisibility(View.VISIBLE);
                                    showNormalEmptyBtn(false);
                                    bIsChanged = true;
                                }
                                break;
                            case MotionEvent.ACTION_UP:
                                System.arraycopy(hints, 1, hints, 0, hints.length - 1);
                                hints[hints.length - 1] = SystemClock.uptimeMillis();
                                iv_kb_button_setting_remove.setVisibility(View.GONE);
                                iv_kb_button_setting_add.setVisibility(View.VISIBLE);
                                if (v.getX() > iv_kb_button_setting_remove.getX() - iv_kb_button_setting_remove.getWidth() / 2 && (v.getX() < (iv_kb_button_setting_remove.getX() + iv_kb_button_setting_remove.getWidth() / 2))
                                        && v.getY() > iv_kb_button_setting_remove.getY() - iv_kb_button_setting_remove.getHeight() / 2 && (v.getY() < (iv_kb_button_setting_remove.getY() + iv_kb_button_setting_remove.getHeight() / 2))
                                ) {
                                    tempCoordinateTbl[2 * k] = 0x8000;
                                    tempCoordinateTbl[2 * k + 1] = 0x8000;
                                    tempAttrTbl[k][0] = 0xff;
                                    tempAttrTbl[k][1] = 0xffff;
                                    tempAttrTbl[k][2] = 0xffff;
                                    v.setVisibility(View.GONE);
                                    iv_btn_setting_kb_ring.setVisibility(View.GONE);
                                }
                                if (SystemClock.uptimeMillis() - hints[0] >= 300) {
                                    bIsLongPress = true;
                                }

                                if ((tempCoordinateTbl[2 * k] != mGlobalVar.coorTbl[2 * k]) || (tempCoordinateTbl[2 * k + 1] != mGlobalVar.coorTbl[2 * k + 1])) {
                                    mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_COORDINATE, k, (tempCoordinateTbl[2 * k] << 16) + tempCoordinateTbl[2 * k + 1], 3);
                                }

                                break;
                        }
                        return bIsLongPress;
                    }
                });
                final int img_id = resIds[a];
                img_button_edit[a].setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        // final int[] temp = tempAttrTbl[k].clone();
                        final int MAX_SHOT_HELP_DELTA = 400;
                        final int MAX_SHOT_HELP_TIME = 400;
                        final int MAX_CON_TAP_TIME = 1000;

                        final int MAX_MACRO_INTERVAL_TIME = 2000;
                        if ((k == 0x88) || (k == 0x89))    // Mouse  wheel
                        {
                            if(Transfer_Con.ENABLE_MOUSE_RELEASE_TIME_OPEN&&mGlobalVar.getIsSupportBagWithMouse_KB()&&(k == 0x88))
                            {
                                if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
                                    if (bIsVirtualMouseShow) {
                                        windowManager.removeView(virtual_mouse_layout);
                                        bIsVirtualMouseShowBackup = true;
                                        bIsVirtualMouseShow = false;
                                    } else {
                                        bIsVirtualMouseShowBackup = false;
                                    }
                                }
                                AlertDialog.Builder builder = new AlertDialog.Builder(FloatMenuService_New.this);
                                View view1 = LayoutInflater.from(FloatMenuService_New.this).inflate(R.layout.kb_attr_setting_mouse_pop_layout, null, false);
                                final ImageView iv_kb_attr_setting_mouse_pop_time_value_del = view1.findViewById(R.id.iv_kb_attr_setting_mouse_pop_time_value_del);
                                final ImageView iv_kb_attr_setting_mouse_pop_time_value_add = view1.findViewById(R.id.iv_kb_attr_setting_mouse_pop_time_value_add);
                                final SeekBar sb_kb_attr_setting_mouse_pop_time_value = view1.findViewById(R.id.sb_kb_attr_setting_mouse_pop_time_value);
                                final TextView tv_kb_attr_setting_mouse_pop_time_value = view1.findViewById(R.id.tv_kb_attr_setting_mouse_pop_time_value);
                                final int MAX_RELEASE_TIME = 2000;
                                final int MIN_RELEASE_TIME = 10;
                                sb_kb_attr_setting_mouse_pop_time_value.setMax(MAX_RELEASE_TIME);

                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                                    sb_kb_attr_setting_mouse_pop_time_value.setMin(MIN_RELEASE_TIME);
                                }

                                if(mGlobalVar.tranGet_Value_retry(Transfer_Con.HID_CMD_RD_DATA,1,0,u8DataBuffer,3))
                                {
                                    sb_kb_attr_setting_mouse_pop_time_value.setProgress((u8DataBuffer[4]&0xff)|((u8DataBuffer[5]&0xff)<<8));
                                }
                                else {
                                    sb_kb_attr_setting_mouse_pop_time_value.setProgress(200);
                                }
                                final int time = sb_kb_attr_setting_mouse_pop_time_value.getProgress();
                                tv_kb_attr_setting_mouse_pop_time_value.setText(String.valueOf(time));
                                builder.setView(view1);
                                builder.setTitle(getResources().getString(R.string.str_global_advanced_setting))
                                        .setIcon(img_id)
                                        .setPositiveButton(getResources().getString(R.string.string_pop_confirm), new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                if(time!=sb_kb_attr_setting_mouse_pop_time_value.getProgress()) {
                                                    if (mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_WR_DATA, 1, sb_kb_attr_setting_mouse_pop_time_value.getProgress(), 3)) {
                                                        Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_file_save_success), Toast.LENGTH_SHORT).show();
                                                    } else {
                                                        Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_file_save_fail), Toast.LENGTH_SHORT).show();
                                                    }
                                                }
                                            }
                                        })
                                                .setNegativeButton(getResources().getString(R.string.string_pop_cancel), new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                            }
                                        });
                                        mDialog = builder.create();
                                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                                            if (Settings.canDrawOverlays(FloatMenuService_New.this))
                                                mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
                                        } else {
                                            mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
                                        }
                                        mDialog.setCanceledOnTouchOutside(false);
                                        mDialog.show();

                                    if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
                                        if (bIsVirtualMouseShowBackup) {
                                            windowManager.addView(virtual_mouse_layout, paramsVirtualMouse);
                                            bIsVirtualMouseShow = true;
                                        }
                                    }
                                    sb_kb_attr_setting_mouse_pop_time_value.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                                    @Override
                                    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                        tv_kb_attr_setting_mouse_pop_time_value.setText(String.valueOf(progress));
                                    }

                                    @Override
                                    public void onStartTrackingTouch(SeekBar seekBar) {
                                    }

                                    @Override
                                    public void onStopTrackingTouch(SeekBar seekBar) {
                                    }
                                });
                                iv_kb_attr_setting_mouse_pop_time_value_del.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        int val = sb_kb_attr_setting_mouse_pop_time_value.getProgress();
                                        if (--val < MIN_RELEASE_TIME)
                                            val = MIN_RELEASE_TIME;
                                        sb_kb_attr_setting_mouse_pop_time_value.setProgress(val);
                                    }
                                });
                                iv_kb_attr_setting_mouse_pop_time_value_add.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        int val = sb_kb_attr_setting_mouse_pop_time_value.getProgress();
                                        if (++val > MAX_RELEASE_TIME)
                                            val = MAX_RELEASE_TIME;
                                        sb_kb_attr_setting_mouse_pop_time_value.setProgress(val);
                                    }
                                });
                            }
                            return;
                        }

                        if (Transfer_Con.ENABLE_SUPPORT_MACRO) {
                            if (bIsMacro_record) {
                                iv_btn_setting_kb_ring.setX(v.getX() - (mImgRingSize - mImageHalfSize));
                                iv_btn_setting_kb_ring.setY(v.getY() - (mImgRingSize - mImageHalfSize));

                                tempAttrEvTblEdit[g_mAutoEventTblLen] = 0x80;  // touch
                                tempAttrEvTblEdit[1 + g_mAutoEventTblLen] = k;  // button
                                tempAttrEvTblEdit[2 + g_mAutoEventTblLen] = 0; // inv time h
                                tempAttrEvTblEdit[3 + g_mAutoEventTblLen] = mMacroIntervalTime; // inv time l
                                tempAttrEvTblEdit[4 + g_mAutoEventTblLen] = 0;   // touch release
                                tempAttrEvTblEdit[5 + g_mAutoEventTblLen] = k;   // button
                                tempAttrEvTblEdit[6 + g_mAutoEventTblLen] = 0; // inv time h
                                tempAttrEvTblEdit[7 + g_mAutoEventTblLen] = mMacroIntervalTime; // inv time l
                                g_mAutoEventTblLen += 8;
                                String str1 = "";
                                for (int a = 2; a < g_mAutoEventTblLen; a += 8) {
                                    str1 += Transfer_Con.tKeyName[(tempAttrEvTblEdit[a + 1])] + getResources().getString(R.string.string_pop_button_setting_advance_event_click_1);
                                }
                                tv_kb_button_setting_macro_msg.setText(getResources().getString(R.string.string_pop_button_setting_advance_macro) + str1);
                                g_mBtnMacroStep++;
                                //Toast.makeText(FloatMenuService_New.this,getResources().getConfiguration().locale.getCountry(),Toast.LENGTH_SHORT).show();
                                if (getResources().getConfiguration().locale.getCountry().equals("CN") || getResources().getConfiguration().locale.getCountry().equals("GB"))
                                    tv_kb_button_setting_macro_tip.setText(String.format("请选择第%d步按键", g_mBtnMacroStep));
                                else
                                    tv_kb_button_setting_macro_tip.setText(String.format("Please select step %d button", g_mBtnMacroStep));
                                return;
                            }
                        }
                        if (g_preButtonIndex != k) {
                            g_preButtonIndex = k;
                            return;
                        }
                        if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
                            if (bIsVirtualMouseShow) {
                                windowManager.removeView(virtual_mouse_layout);
                                bIsVirtualMouseShowBackup = true;
                                bIsVirtualMouseShow = false;
                            } else {
                                bIsVirtualMouseShowBackup = false;
                            }
                        }
                        AlertDialog.Builder builder = new AlertDialog.Builder(FloatMenuService_New.this);
                        View view = LayoutInflater.from(FloatMenuService_New.this).inflate(R.layout.kb_attr_setting_pop_layout, null, false);
                        final RadioButton rb_direct = view.findViewById(R.id.rb_kb_attr_setting_pop_dir);
                        final RadioButton rb_continue_tap = view.findViewById(R.id.rb_kb_attr_setting_pop_continue_tap);
                        final RadioButton rb_normal = view.findViewById(R.id.rb_kb_attr_setting_pop_normal);
                        final RadioButton rb_full = view.findViewById(R.id.rb_kb_attr_setting_dir_full);
                        final RadioButton rb_limit = view.findViewById(R.id.rb_kb_attr_setting_dir_limit);
                        final RadioButton rb_get_down = view.findViewById(R.id.rb_kb_attr_setting_pop_get_down);
                        final RadioButton rb_shot_help = view.findViewById(R.id.rb_kb_attr_setting_pop_shot_help);
                        final RadioButton rb_multi_button = view.findViewById(R.id.rb_kb_attr_setting_pop_multi);
                        final LinearLayout kb_attr_setting_pop_dir_layout = view.findViewById(R.id.kb_attr_setting_pop_dir_layout);
                        final LinearLayout kb_attr_setting_pop_continue_tap_layout = view.findViewById(R.id.kb_attr_setting_pop_continue_tap_layout);
                        final LinearLayout kb_attr_setting_pop_left_layout = view.findViewById(R.id.kb_attr_setting_pop_left_layout);

                        final ImageView iv_kb_attr_setting_pop_tap_time_del = view.findViewById(R.id.iv_kb_attr_setting_pop_tap_time_del);
                        final ImageView iv_kb_attr_setting_pop_tap_time_add = view.findViewById(R.id.iv_kb_attr_setting_pop_tap_time_add);
                        final SeekBar sb_kb_attr_setting_pop_tap_time = view.findViewById(R.id.sb_kb_attr_setting_pop_tap_time);
                        final TextView tv_kb_attr_setting_pop_tap_time_value = view.findViewById(R.id.tv_kb_attr_setting_pop_tap_time_value);
                        sb_kb_attr_setting_pop_tap_time.setMax(MAX_CON_TAP_TIME);
                        sb_kb_attr_setting_pop_tap_time.setProgress(50);

                        final LinearLayout kb_attr_setting_pop_shot_help_layout = view.findViewById(R.id.kb_attr_setting_pop_shot_help_layout);
                        final SeekBar sb_kb_attr_setting_pop_shot_help_delta = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_delta);
                        sb_kb_attr_setting_pop_shot_help_delta.setMax(MAX_SHOT_HELP_DELTA);
                        sb_kb_attr_setting_pop_shot_help_delta.setProgress(29);
                        final SeekBar sb_kb_attr_setting_pop_shot_help_time = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_time);
                        sb_kb_attr_setting_pop_shot_help_time.setMax(MAX_SHOT_HELP_TIME);
                        sb_kb_attr_setting_pop_shot_help_time.setProgress(MAX_SHOT_HELP_TIME - 16);
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                            sb_kb_attr_setting_pop_shot_help_delta.setMin(1);
                            sb_kb_attr_setting_pop_shot_help_time.setMin(1);
                            sb_kb_attr_setting_pop_tap_time.setMin(1);
                        }
                        final TextView tv_kb_attr_setting_pop_shot_help_delta_value = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_delta_value);
                        final TextView tv_kb_attr_setting_pop_shot_help_time_value = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_time_value);

                        final SeekBar sb_kb_attr_setting_pop_shot_help_delta_1 = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_delta_1);
                        sb_kb_attr_setting_pop_shot_help_delta_1.setMax(MAX_SHOT_HELP_DELTA);
                        sb_kb_attr_setting_pop_shot_help_delta_1.setProgress(58);
                        final SeekBar sb_kb_attr_setting_pop_shot_help_time_1 = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_time_1);
                        sb_kb_attr_setting_pop_shot_help_time_1.setMax(MAX_SHOT_HELP_TIME);
                        sb_kb_attr_setting_pop_shot_help_time_1.setProgress(MAX_SHOT_HELP_TIME - 16);

                        final TextView tv_kb_attr_setting_pop_shot_help_delta_value_1 = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_delta_value_1);
                        final TextView tv_kb_attr_setting_pop_shot_help_time_value_1 = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_time_value_1);

                        final SeekBar sb_kb_attr_setting_pop_shot_help_delta_2 = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_delta_2);
                        sb_kb_attr_setting_pop_shot_help_delta_2.setMax(MAX_SHOT_HELP_DELTA);
                        sb_kb_attr_setting_pop_shot_help_delta_2.setProgress(15);
                        final SeekBar sb_kb_attr_setting_pop_shot_help_time_2 = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_time_2);
                        sb_kb_attr_setting_pop_shot_help_time_2.setMax(MAX_SHOT_HELP_TIME);
                        sb_kb_attr_setting_pop_shot_help_time_2.setProgress(MAX_SHOT_HELP_TIME - 16);

                        final TextView tv_kb_attr_setting_pop_shot_help_delta_value_2 = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_delta_value_2);
                        final TextView tv_kb_attr_setting_pop_shot_help_time_value_2 = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_time_value_2);

                        final SeekBar sb_kb_attr_setting_pop_shot_help_delta_3 = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_delta_3);
                        sb_kb_attr_setting_pop_shot_help_delta_3.setMax(MAX_SHOT_HELP_DELTA);
                        sb_kb_attr_setting_pop_shot_help_delta_3.setProgress(1);
                        final SeekBar sb_kb_attr_setting_pop_shot_help_time_3 = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_time_3);
                        sb_kb_attr_setting_pop_shot_help_time_3.setMax(MAX_SHOT_HELP_TIME);
                        sb_kb_attr_setting_pop_shot_help_time_3.setProgress(MAX_SHOT_HELP_TIME - 16);
                        final TextView tv_kb_attr_setting_pop_shot_help_delta_value_3 = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_delta_value_3);
                        final TextView tv_kb_attr_setting_pop_shot_help_time_value_3 = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_time_value_3);


                        final SeekBar sb_kb_attr_setting_pop_shot_help_delta_4 = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_delta_4);
                        sb_kb_attr_setting_pop_shot_help_delta_4.setMax(MAX_SHOT_HELP_DELTA);
                        sb_kb_attr_setting_pop_shot_help_delta_4.setProgress(1);
                        final SeekBar sb_kb_attr_setting_pop_shot_help_time_4 = view.findViewById(R.id.sb_kb_attr_setting_pop_shot_help_time_4);
                        sb_kb_attr_setting_pop_shot_help_time_4.setMax(MAX_SHOT_HELP_TIME);
                        sb_kb_attr_setting_pop_shot_help_time_4.setProgress(MAX_SHOT_HELP_TIME - 16);

                        final TextView tv_kb_attr_setting_pop_shot_help_delta_value_4 = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_delta_value_4);
                        final TextView tv_kb_attr_setting_pop_shot_help_time_value_4 = view.findViewById(R.id.tv_kb_attr_setting_pop_shot_help_time_value_4);

                        final LinearLayout kb_attr_setting_pop_shot_help_setting = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting);
                        final LinearLayout kb_attr_setting_pop_shot_help_setting_1 = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_1);
                        final LinearLayout kb_attr_setting_pop_shot_help_setting_2 = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_2);
                        final LinearLayout kb_attr_setting_pop_shot_help_setting_3 = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_3);
                        final LinearLayout kb_attr_setting_pop_shot_help_setting_off = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_off);
                        final LinearLayout kb_attr_setting_pop_shot_help_setting_crouch_layout = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_crouch_layout);
                        final LinearLayout kb_attr_setting_pop_shot_help_setting_lie_down_layout = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_lie_down_layout);
                        final LinearLayout kb_attr_setting_pop_shot_help_setting_layout = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_layout);
                        final LinearLayout kb_attr_setting_pop_shot_help_setting_standing_layout = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_standing_layout);
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                            sb_kb_attr_setting_pop_shot_help_delta_1.setMin(1);
                            sb_kb_attr_setting_pop_shot_help_time_1.setMin(1);
                            sb_kb_attr_setting_pop_shot_help_delta_2.setMin(1);
                            sb_kb_attr_setting_pop_shot_help_time_2.setMin(1);
                            sb_kb_attr_setting_pop_shot_help_delta_3.setMin(1);
                            sb_kb_attr_setting_pop_shot_help_time_3.setMin(1);
                            sb_kb_attr_setting_pop_shot_help_delta_4.setMin(1);
                            sb_kb_attr_setting_pop_shot_help_time_4.setMin(1);
                        }

                        final AddAndSubView item_kb_attr_setting_pop_multi = view.findViewById(R.id.item_kb_attr_setting_pop_multi);
                        final LinearLayout kb_attr_setting_pop_button_split_layout = view.findViewById(R.id.kb_attr_setting_pop_button_split_layout);
                        final RadioButton rb_macro_btn = view.findViewById(R.id.rb_kb_attr_setting_pop_macro_btn);
                        final RadioButton rb_macro_adv = view.findViewById(R.id.rb_kb_attr_setting_pop_macro_adv);
                        final RadioButton rb_kb_attr_setting_pop_macro_down = view.findViewById(R.id.rb_kb_attr_setting_pop_macro_down);
                        final RadioButton rb_kb_attr_setting_pop_macro_up = view.findViewById(R.id.rb_kb_attr_setting_pop_macro_up);
                        final RadioButton rb_kb_attr_setting_pop_macro_loop = view.findViewById(R.id.rb_kb_attr_setting_pop_macro_loop);

                        final LinearLayout kb_attr_setting_pop_macro_btn_layout = view.findViewById(R.id.kb_attr_setting_pop_macro_btn_layout);
                        final Button btn_kb_attr_setting_pop_macro_rec = view.findViewById(R.id.btn_kb_attr_setting_pop_macro_rec);
                        final Button btn_kb_attr_setting_pop_macro_load = view.findViewById(R.id.btn_kb_attr_setting_pop_macro_load);
                        final Button btn_kb_attr_setting_pop_macro_save = view.findViewById(R.id.btn_kb_attr_setting_pop_macro_save);
                        final Button btn_kb_attr_setting_pop_macro_edit = view.findViewById(R.id.btn_kb_attr_setting_pop_macro_edit);
                        tv_kb_attr_setting_pop_macro_desc = view.findViewById(R.id.tv_kb_attr_setting_pop_macro_desc);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_del = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_del);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_add = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_add);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_del = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_del);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_add = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_add);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_del_1 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_del_1);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_add_1 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_add_1);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_del_1 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_del_1);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_add_1 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_add_1);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_del_2 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_del_2);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_add_2 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_add_2);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_del_2 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_del_2);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_add_2 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_add_2);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_del_3 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_del_3);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_add_3 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_add_3);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_del_3 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_del_3);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_add_3 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_add_3);

                        final LinearLayout kb_attr_setting_pop_shot_help_setting_4 = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_4);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_del_4 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_del_4);
                        final ImageView iv_kb_attr_setting_pop_shot_help_delta_add_4 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_delta_add_4);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_del_4 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_del_4);
                        final ImageView iv_kb_attr_setting_pop_shot_help_time_add_4 = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_time_add_4);


                        final RadioButton rb_kb_attr_setting_pop_shot_help_setting = view.findViewById(R.id.rb_kb_attr_setting_pop_shot_help_setting);
                        final RadioButton rb_kb_attr_setting_pop_shot_help_setting_1 = view.findViewById(R.id.rb_kb_attr_setting_pop_shot_help_setting_1);
                        final RadioButton rb_kb_attr_setting_pop_shot_help_setting_2 = view.findViewById(R.id.rb_kb_attr_setting_pop_shot_help_setting_2);
                        final RadioButton rb_kb_attr_setting_pop_shot_help_setting_3 = view.findViewById(R.id.rb_kb_attr_setting_pop_shot_help_setting_3);

                        final CheckBox cb_kb_attr_setting_pop_shot_help_setting = view.findViewById(R.id.cb_kb_attr_setting_pop_shot_help_setting);
                        final CheckBox cb_kb_attr_setting_pop_shot_help_setting_1 = view.findViewById(R.id.cb_kb_attr_setting_pop_shot_help_setting_1);
                        final CheckBox cb_kb_attr_setting_pop_shot_help_setting_2 = view.findViewById(R.id.cb_kb_attr_setting_pop_shot_help_setting_2);
                        final CheckBox cb_kb_attr_setting_pop_shot_help_setting_3 = view.findViewById(R.id.cb_kb_attr_setting_pop_shot_help_setting_3);
                        final CheckBox cb_kb_attr_setting_pop_shot_help_setting_off = view.findViewById(R.id.cb_kb_attr_setting_pop_shot_help_setting_off);
                        final CheckBox cb_kb_attr_setting_pop_shot_help_setting_crouch = view.findViewById(R.id.cb_kb_attr_setting_pop_shot_help_setting_crouch);
                        final CheckBox cb_kb_attr_setting_pop_shot_help_setting_lie_down = view.findViewById(R.id.cb_kb_attr_setting_pop_shot_help_setting_lie_down);
                        final CheckBox cb_kb_attr_setting_pop_shot_help_setting_standing = view.findViewById(R.id.cb_kb_attr_setting_pop_shot_help_setting_standing);

                        final LinearLayout kb_attr_setting_pop_shot_help_setting_trigger_layout = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_trigger_layout);
                        final CheckBox cb_kb_attr_setting_pop_shot_help_setting_trigger = view.findViewById(R.id.cb_kb_attr_setting_pop_shot_help_setting_trigger);
                        final RadioButton rb_kb_attr_setting_pop_shot_help_setting_press = view.findViewById(R.id.rb_kb_attr_setting_pop_shot_help_setting_press);
                        final RadioButton rb_kb_attr_setting_pop_shot_help_setting_click = view.findViewById(R.id.rb_kb_attr_setting_pop_shot_help_setting_click);
                        final RadioButton rb_kb_attr_setting_pop_shot_help_setting_click_on = view.findViewById(R.id.rb_kb_attr_setting_pop_shot_help_setting_click_on);
                        final RadioGroup rg_attr_setting_pop_shot_help_setting_on_off_layout = view.findViewById(R.id.rg_attr_setting_pop_shot_help_setting_on_off_layout);
                        final LinearLayout kb_attr_setting_pop_special_attr_layout = view.findViewById(R.id.kb_attr_setting_pop_special_attr_layout);
                        final ImageView iv_kb_attr_setting_pop_special_attr_shot_help = view.findViewById(R.id.iv_kb_attr_setting_pop_special_attr_shot_help);


                        final RadioButton rb_kb_attr_setting_pop_mouse_relation = view.findViewById(R.id.rb_kb_attr_setting_pop_mouse_relation);
                        final LinearLayout kb_attr_setting_pop_mouse_relation_layout = view.findViewById(R.id.kb_attr_setting_pop_mouse_relation_layout);
                        final RadioButton rb_kb_attr_setting_pop_mouse_relation_bag = view.findViewById(R.id.rb_kb_attr_setting_pop_mouse_relation_bag);
                        final RadioButton rb_kb_attr_setting_pop_mouse_relation_null = view.findViewById(R.id.rb_kb_attr_setting_pop_mouse_relation_null);

                        final ImageView iv_kb_attr_setting_pop_macro_time_del = view.findViewById(R.id.iv_kb_attr_setting_pop_macro_time_del);
                        final ImageView iv_kb_attr_setting_pop_macro_time_add = view.findViewById(R.id.iv_kb_attr_setting_pop_macro_time_add);
                        final SeekBar sb_kb_attr_setting_pop_macro_time = view.findViewById(R.id.sb_kb_attr_setting_pop_macro_time);
                        final TextView tv_kb_attr_setting_pop_macro_time_value = view.findViewById(R.id.tv_kb_attr_setting_pop_macro_time_value);

                        final LinearLayout kb_attr_setting_pop_shot_help_setting_switch_params_layout = view.findViewById(R.id.kb_attr_setting_pop_shot_help_setting_switch_params_layout);
                        //final ImageView iv_kb_attr_setting_pop_shot_help_setting_switch_params = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting_switch_params);

                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                            sb_kb_attr_setting_pop_macro_time.setMin(1);
                        }
                        sb_kb_attr_setting_pop_macro_time.setMax(2000);
                        sb_kb_attr_setting_pop_macro_time.setProgress(mMacroIntervalTime);
                        tv_kb_attr_setting_pop_macro_time_value.setText(String.valueOf(mMacroIntervalTime));

                        mShotHelpImageIndex[0] = 0x1E;  // 1
                        mShotHelpImageIndex[1] = 0x1F;  // 2
                        mShotHelpImageIndex[2] = 0x24;  // 3
                        mShotHelpImageIndex[3] = 0x25;  // 4
                        mShotHelpImageIndex[4] = 0x21;  // off
                        mShotHelpImageIndex[5] = 0x06;  // crouch
                        mShotHelpImageIndex[6] = 0x1D;  // lie dpwn
                        mShotHelpImageIndex[7] = 0x2C;  // stand
                        mShotHelpImageIndex[8] = 0x8b;  // press
                        mShotHelpImageIndex[9] = 0x3a;  // f1
                        mShotHelpImageIndex[10] = 0x3b; // f2
                        mShotHelpImageIndex[11] = 0x3C; // f3
                        mShotHelpImageIndex[12] = 0x3D; // f4
                        mShotHelpImageIndex[13] = 0x3E; // f5
                        mShotHelpImageIndex[14] = 0x35; // ~

                        mShotHelpImageIndexBackup = mShotHelpImageIndex.clone();

                        final LinearLayout kb_attr_setting_pop_reset_view_layout = view.findViewById(R.id.kb_attr_setting_pop_reset_view_layout);
                        final RadioButton rb_kb_attr_setting_reset_view_on = view.findViewById(R.id.rb_kb_attr_setting_reset_view_on);
                        final RadioButton rb_kb_attr_setting_reset_view_off = view.findViewById(R.id.rb_kb_attr_setting_reset_view_off);
                        rb_kb_attr_setting_reset_view_off.setChecked(true);
                        final LinearLayout kb_attr_setting_pop_get_down_layout = view.findViewById(R.id.kb_attr_setting_pop_get_down_layout);
                        if (mGlobalVar.getIsSupportAttributeEventTable_KB()) {
                            rb_continue_tap.setVisibility(View.VISIBLE);
                            rb_get_down.setVisibility(View.VISIBLE);
                        }

                        if (mGlobalVar.getIsSupportKeySplit_KB()) {
                            rb_shot_help.setVisibility(View.VISIBLE);
                            rb_multi_button.setVisibility(View.VISIBLE);
                            if (Transfer_Con.ENABLE_SUPPORT_MACRO) {
                                rb_macro_btn.setVisibility(View.VISIBLE);
                                rb_kb_attr_setting_pop_macro_down.setChecked(true);
                                //rb_macro_adv.setVisibility(View.VISIBLE);
                            }
                        }

                        if(Transfer_Con.ENABLE_OPEN_BAG_WITH_MOUSE)
                        {
                            if(mGlobalVar.getIsSupportBagWithMouse_KB())
                                rb_kb_attr_setting_pop_mouse_relation.setVisibility(View.VISIBLE);
                        }

                        if(mGlobalVar.getIsSupportShptHelpInsertDefine_KB())
                        {
                            rb_kb_attr_setting_pop_shot_help_setting_click_on.setVisibility(View.VISIBLE);
                            kb_attr_setting_pop_shot_help_setting_switch_params_layout.setVisibility(View.VISIBLE);
                            if(mGlobalVar.tranGet_Value_retry(Transfer_Con.HID_CMD_GET_SHOT_INDEX,0,0,u8DataBuffer,3))
                            {
                                int index=0x35;
                                if((u8DataBuffer[0]&0x7F)==0)
                                {
                                    switch (u8DataBuffer[4]&0xff)
                                    {
                                        case 0x01:
                                            index= 0x80;
                                            break;
                                        case 0x02:
                                            index= 0x81;
                                            break;
                                        case 0x04:
                                            index= 0x82;
                                            break;
                                        case 0x08:
                                            index= 0x83;
                                            break;
                                        case 0x10:
                                            index= 0x84;
                                            break;
                                        case 0x20:
                                            index= 0x85;
                                            break;
                                        case 0x40:
                                            index= 0x86;
                                            break;
                                        case 0x80:
                                            index= 0x87;
                                            break;
                                    }
                                }
                                else if((u8DataBuffer[0]&0x7F)==1)
                                {
                                    index = u8DataBuffer[4]&0xff;
                                }
                                else if((u8DataBuffer[0]&0x7F)==2)
                                {
                                    switch (u8DataBuffer[4]&0xff)
                                    {
                                        case 0x01:
                                            index= 0x8A;
                                            break;
                                        case 0x02:
                                            index= 0x8B;
                                            break;
                                        case 0x04:
                                            index= 0x8C;
                                            break;
                                        case 0x08:
                                            index= 0x8D;
                                            break;
                                        case 0x10:
                                            index= 0x8E;
                                            break;
                                        case 0x20:
                                            index= 0x8F;
                                            break;
                                    }
                                }
                                mShotHelpImageIndex[14] = index; // ~
                                mShotHelpImageIndexBackup[14]= index; // ~
                                Log.d(TAG,"------------------------------------------------------------->"+String.valueOf(mShotHelpImageIndex[14]));
                            }
                        }

                        if ((tempAttrTbl[k][0] == Transfer_Con.bSkillWithDirect) || (tempAttrTbl[k][0] == Transfer_Con.ATTR_VIEW_MOVE)) {
                            kb_attr_setting_pop_dir_layout.setVisibility(View.VISIBLE);
                            rb_direct.setChecked(true);
                            if (tempAttrTbl[k][1] != 0xffff) {
                                rb_limit.setChecked(true);
                            } else {
                                rb_full.setChecked(true);
                            }
                        } else if (tempAttrTbl[k][0] == Transfer_Con.bContinueClick) {
                            rb_continue_tap.setChecked(true);
                            kb_attr_setting_pop_continue_tap_layout.setVisibility(View.VISIBLE);
                            if ((tempAttrTbl[k][1] == 0xffff) && (tempAttrTbl[k][2] == 0xffff)) {
                                sb_kb_attr_setting_pop_tap_time.setProgress(50);
                            } else {
                                sb_kb_attr_setting_pop_tap_time.setProgress(Math.min(1000, tempAttrTbl[k][2]));
                            }
                            tv_kb_attr_setting_pop_tap_time_value.setText(String.valueOf(sb_kb_attr_setting_pop_tap_time.getProgress()));
                        } else if (tempAttrTbl[k][0] == Transfer_Con.ATTR_GET_DOWN) {
                            rb_get_down.setChecked(true);
                            kb_attr_setting_pop_get_down_layout.setVisibility(View.VISIBLE);
                        } else if ((tempAttrTbl[k][0] == Transfer_Con.bFPSPullGunDown) && mGlobalVar.getIsSupportKeySplit_KB()) {
                            kb_attr_setting_pop_shot_help_layout.setVisibility(View.VISIBLE);
                            rb_shot_help.setChecked(true);
                            /*
                            String str ="shot: ";
                            for(int a=0;a<tempAttrTbl[k][2];a++)
                            {
                                str += String.valueOf(tempAttrEvTbl[tempAttrTbl[k][1]+a])+"; ";
                            }
                            Log.d(TAG,str);
                            */
                            if (mGlobalVar.getIsSupportMultiShotHelp_KB()) {
                                int delta, time;
                                kb_attr_setting_pop_shot_help_setting_1.setVisibility(View.VISIBLE);
                                kb_attr_setting_pop_shot_help_setting_2.setVisibility(View.VISIBLE);
                                kb_attr_setting_pop_shot_help_setting_3.setVisibility(View.VISIBLE);
                                kb_attr_setting_pop_shot_help_setting_off.setVisibility(View.VISIBLE);
                                kb_attr_setting_pop_shot_help_setting_layout.setVisibility(View.VISIBLE);
                                if(mGlobalVar.getIsSupportShptHelpInsert_KB())
                                {
                                    kb_attr_setting_pop_shot_help_setting_4.setVisibility(View.VISIBLE);
                                }

                                delta = (tempAttrEvTbl[tempAttrTbl[k][1]] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 1];
                                time = MAX_SHOT_HELP_TIME + 1 - ((tempAttrEvTbl[tempAttrTbl[k][1] + 2] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 3]);
                                tv_kb_attr_setting_pop_shot_help_delta_value.setText(String.valueOf(delta));
                                tv_kb_attr_setting_pop_shot_help_time_value.setText(String.valueOf(time));
                                sb_kb_attr_setting_pop_shot_help_delta.setProgress(delta);
                                sb_kb_attr_setting_pop_shot_help_time.setProgress(time);
                                if (tempAttrTbl[k][2] >= 17) {
                                    delta = (tempAttrEvTbl[tempAttrTbl[k][1] + 4] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 5];
                                    time = MAX_SHOT_HELP_TIME + 1 - ((tempAttrEvTbl[tempAttrTbl[k][1] + 6] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 7]);
                                    tv_kb_attr_setting_pop_shot_help_delta_value_1.setText(String.valueOf(delta));
                                    tv_kb_attr_setting_pop_shot_help_time_value_1.setText(String.valueOf(time));
                                    sb_kb_attr_setting_pop_shot_help_delta_1.setProgress(delta);
                                    sb_kb_attr_setting_pop_shot_help_time_1.setProgress(time);

                                    delta = (tempAttrEvTbl[tempAttrTbl[k][1] + 8] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 9];
                                    time = MAX_SHOT_HELP_TIME + 1 - ((tempAttrEvTbl[tempAttrTbl[k][1] + 10] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 11]);
                                    tv_kb_attr_setting_pop_shot_help_delta_value_2.setText(String.valueOf(delta));
                                    tv_kb_attr_setting_pop_shot_help_time_value_2.setText(String.valueOf(time));
                                    sb_kb_attr_setting_pop_shot_help_delta_2.setProgress(delta);
                                    sb_kb_attr_setting_pop_shot_help_time_2.setProgress(time);

                                    delta = (tempAttrEvTbl[tempAttrTbl[k][1] + 12] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 13];
                                    time = MAX_SHOT_HELP_TIME + 1 - ((tempAttrEvTbl[tempAttrTbl[k][1] + 14] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 15]);
                                    tv_kb_attr_setting_pop_shot_help_delta_value_3.setText(String.valueOf(delta));
                                    tv_kb_attr_setting_pop_shot_help_time_value_3.setText(String.valueOf(time));
                                    sb_kb_attr_setting_pop_shot_help_delta_3.setProgress(delta);
                                    sb_kb_attr_setting_pop_shot_help_time_3.setProgress(time);
                                    if(mGlobalVar.getIsSupportShptHelpInsert_KB())
                                    {
                                        if(tempAttrTbl[k][2] >= 21)
                                        {
                                            delta = (tempAttrEvTbl[tempAttrTbl[k][1] + 16] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 17];
                                            time = MAX_SHOT_HELP_TIME + 1 - ((tempAttrEvTbl[tempAttrTbl[k][1] + 18] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 19]);
                                            tv_kb_attr_setting_pop_shot_help_delta_value_4.setText(String.valueOf(delta));
                                            tv_kb_attr_setting_pop_shot_help_time_value_4.setText(String.valueOf(time));
                                            sb_kb_attr_setting_pop_shot_help_delta_4.setProgress(delta);
                                            sb_kb_attr_setting_pop_shot_help_time_4.setProgress(time);
                                        }
                                        else
                                        {
                                            tv_kb_attr_setting_pop_shot_help_delta_value_4.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_delta_4.getProgress()));
                                            tv_kb_attr_setting_pop_shot_help_time_value_4.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_time_4.getProgress()));
                                        }
                                    }
                                    else {
                                        kb_attr_setting_pop_shot_help_setting_4.setVisibility(View.GONE);
                                        if (!mGlobalVar.getIsSupportShotHelpPosture_KB()) {
                                            rb_kb_attr_setting_pop_shot_help_setting.setVisibility(View.VISIBLE);
                                            rb_kb_attr_setting_pop_shot_help_setting_1.setVisibility(View.VISIBLE);
                                            rb_kb_attr_setting_pop_shot_help_setting_2.setVisibility(View.VISIBLE);
                                            rb_kb_attr_setting_pop_shot_help_setting_3.setVisibility(View.VISIBLE);
                                            if (tempAttrEvTbl[tempAttrTbl[k][1] + 16] == 1) {
                                                kb_attr_setting_pop_shot_help_setting_1.setBackgroundColor(Color.rgb(0x80, 0xe0, 0xe0));
                                                rb_kb_attr_setting_pop_shot_help_setting_1.setChecked(true);
                                            } else if (tempAttrEvTbl[tempAttrTbl[k][1] + 16] == 2) {
                                                kb_attr_setting_pop_shot_help_setting_2.setBackgroundColor(Color.rgb(0x80, 0xe0, 0xe0));
                                                rb_kb_attr_setting_pop_shot_help_setting_2.setChecked(true);
                                            } else if (tempAttrEvTbl[tempAttrTbl[k][1] + 16] == 3) {
                                                kb_attr_setting_pop_shot_help_setting_3.setBackgroundColor(Color.rgb(0x80, 0xe0, 0xe0));
                                                rb_kb_attr_setting_pop_shot_help_setting_3.setChecked(true);
                                            } else {
                                                kb_attr_setting_pop_shot_help_setting.setBackgroundColor(Color.rgb(0x80, 0xe0, 0xe0));
                                                rb_kb_attr_setting_pop_shot_help_setting.setChecked(true);
                                            }
                                        }
                                    }
                                    if (mGlobalVar.getIsSupportShotHelpPosture_KB()) {
                                        kb_attr_setting_pop_shot_help_setting_crouch_layout.setVisibility(View.VISIBLE);
                                        kb_attr_setting_pop_shot_help_setting_lie_down_layout.setVisibility(View.VISIBLE);
                                        kb_attr_setting_pop_shot_help_setting_standing_layout.setVisibility(View.VISIBLE);
                                        if (mGlobalVar.getIsSupportShotHelpTrigger_KB()) {
                                            kb_attr_setting_pop_shot_help_setting_trigger_layout.setVisibility(View.VISIBLE);
                                            if(mGlobalVar.getIsSupportShotHelpTrigger1_KB())
                                                rg_attr_setting_pop_shot_help_setting_on_off_layout.setVisibility(View.VISIBLE);
                                        }

                                        for (int a = 4; a < mGlobalVar.getDirectCenterIndex(); a++) {
                                            if ((a > 0x63) && (a < 0x80))
                                                continue;
                                            else if(mGlobalVar.switchMouseToKeyEvent((mGlobalVar.getSwitchToMouseKey_KB()&0xff00)>>8,mGlobalVar.getSwitchToMouseKey_KB()&0xff)==a)
                                                continue;
                                            if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SW_WITH_BTN) {
                                                if (tempAttrTbl[a][2] == 0) {
                                                    cb_kb_attr_setting_pop_shot_help_setting.setChecked(true);
                                                    mShotHelpImageIndex[0] = a;
                                                    mShotHelpImageIndexBackup[0] = a;
                                                } else if (tempAttrTbl[a][2] == 1) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_1.setChecked(true);
                                                    mShotHelpImageIndex[1] = a;
                                                    mShotHelpImageIndexBackup[1] = a;
                                                } else if (tempAttrTbl[a][2] == 2) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_2.setChecked(true);
                                                    mShotHelpImageIndex[2] = a;
                                                    mShotHelpImageIndexBackup[2] = a;
                                                } else if (tempAttrTbl[a][2] == 3) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_3.setChecked(true);
                                                    mShotHelpImageIndex[3] = a;
                                                    mShotHelpImageIndexBackup[3] = a;
                                                }
                                            } else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_ONOFF_WITH_BTN) {
                                                if (tempAttrTbl[a][2] == Transfer_Con.bFPSPullGunDown) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_off.setChecked(true);
                                                    mShotHelpImageIndex[4] = a;
                                                    mShotHelpImageIndexBackup[4] = a;
                                                }
                                            } else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SWITCH_POSTURE) {
                                                if (tempAttrTbl[a][2] <= 50) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_lie_down.setChecked(true);
                                                    mShotHelpImageIndex[6] = a;
                                                    mShotHelpImageIndexBackup[6] = a;
                                                } else if (tempAttrTbl[a][2] <= 75) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_crouch.setChecked(true);
                                                    mShotHelpImageIndex[5] = a;
                                                    mShotHelpImageIndexBackup[5] = a;
                                                } else if (tempAttrTbl[a][2] <= 100) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_standing.setChecked(true);
                                                    mShotHelpImageIndex[7] = a;
                                                    mShotHelpImageIndexBackup[7] = a;
                                                }
                                            } else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_ON_WHEN_PRESS) {
                                                cb_kb_attr_setting_pop_shot_help_setting_trigger.setChecked(true);
                                                rb_kb_attr_setting_pop_shot_help_setting_press.setChecked(true);
                                                mShotHelpImageIndex[8] = a;
                                                mShotHelpImageIndexBackup[8] = a;
                                            }
                                            else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_TONGLE_ONOFF) {
                                                cb_kb_attr_setting_pop_shot_help_setting_trigger.setChecked(true);
                                                rb_kb_attr_setting_pop_shot_help_setting_click.setChecked(true);
                                                mShotHelpImageIndex[8] = a;
                                                mShotHelpImageIndexBackup[8] = a;
                                            }
                                            else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_TONGLE_ON) {
                                                cb_kb_attr_setting_pop_shot_help_setting_trigger.setChecked(true);
                                                rb_kb_attr_setting_pop_shot_help_setting_click_on.setChecked(true);
                                                mShotHelpImageIndex[8] = a;
                                                mShotHelpImageIndexBackup[8] = a;
                                            }else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SW_WITH_BTN_1) {
                                                if (tempAttrTbl[a][2] == 0) {
                                                    cb_kb_attr_setting_pop_shot_help_setting.setChecked(true);
                                                    mShotHelpImageIndex[0] = a;
                                                    mShotHelpImageIndexBackup[0] = a;
                                                } else if (tempAttrTbl[a][2] == 1) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_1.setChecked(true);
                                                    mShotHelpImageIndex[1] = a;
                                                    mShotHelpImageIndexBackup[1] = a;
                                                } else if (tempAttrTbl[a][2] == 2) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_2.setChecked(true);
                                                    mShotHelpImageIndex[2] = a;
                                                    mShotHelpImageIndexBackup[2] = a;
                                                } else if (tempAttrTbl[a][2] == 3) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_3.setChecked(true);
                                                    mShotHelpImageIndex[3] = a;
                                                    mShotHelpImageIndexBackup[3] = a;
                                                }
                                            }
                                            else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SW_WITH_BTN_OFF) {
                                                if (tempAttrTbl[a][2] == 0) {
                                                    cb_kb_attr_setting_pop_shot_help_setting.setChecked(true);
                                                    mShotHelpImageIndex[0] = a;
                                                    mShotHelpImageIndexBackup[0] = a;
                                                } else if (tempAttrTbl[a][2] == 1) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_1.setChecked(true);
                                                    mShotHelpImageIndex[1] = a;
                                                    mShotHelpImageIndexBackup[1] = a;
                                                } else if (tempAttrTbl[a][2] == 2) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_2.setChecked(true);
                                                    mShotHelpImageIndex[2] = a;
                                                    mShotHelpImageIndexBackup[2] = a;
                                                } else if (tempAttrTbl[a][2] == 3) {
                                                    cb_kb_attr_setting_pop_shot_help_setting_3.setChecked(true);
                                                    mShotHelpImageIndex[3] = a;
                                                    mShotHelpImageIndexBackup[3] = a;
                                                }
                                            }else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SWITCH) {
                                                if (tempAttrTbl[a][2] == 0) {
                                                    mShotHelpImageIndex[10] = a;
                                                    mShotHelpImageIndexBackup[10] = a;
                                                } else if (tempAttrTbl[a][2] == 1) {
                                                    mShotHelpImageIndex[11] = a;
                                                    mShotHelpImageIndexBackup[11] = a;
                                                } else if (tempAttrTbl[a][2] == 2) {
                                                    mShotHelpImageIndex[12] = a;
                                                    mShotHelpImageIndexBackup[12] = a;
                                                } else if (tempAttrTbl[a][2] == 3) {
                                                    mShotHelpImageIndex[13] = a;
                                                    mShotHelpImageIndexBackup[13] = a;
                                                }
                                            }if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_ONOFF) {
                                                if (tempAttrTbl[a][2] == Transfer_Con.bFPSPullGunDown) {
                                                    mShotHelpImageIndex[9] = a;
                                                    mShotHelpImageIndexBackup[9] = a;
                                                }
                                            }
                                        }
                                    } else {
                                        if (tempAttrTbl[0x1E][0] == 0x32)
                                            cb_kb_attr_setting_pop_shot_help_setting.setChecked(true);

                                        if (tempAttrTbl[0x1F][0] == 0x32)
                                            cb_kb_attr_setting_pop_shot_help_setting_1.setChecked(true);

                                        if (tempAttrTbl[0x21][0] == 0x33)
                                            cb_kb_attr_setting_pop_shot_help_setting_off.setChecked(true);
                                    }
                                } else {
                                    delta = 1;
                                    time = MAX_SHOT_HELP_TIME;
                                    tv_kb_attr_setting_pop_shot_help_delta_value_1.setText(String.valueOf(delta));
                                    tv_kb_attr_setting_pop_shot_help_time_value_1.setText(String.valueOf(time));
                                    sb_kb_attr_setting_pop_shot_help_delta_1.setProgress(delta);
                                    sb_kb_attr_setting_pop_shot_help_time_1.setProgress(time);
                                    tv_kb_attr_setting_pop_shot_help_delta_value_2.setText(String.valueOf(delta));
                                    tv_kb_attr_setting_pop_shot_help_time_value_2.setText(String.valueOf(time));
                                    sb_kb_attr_setting_pop_shot_help_delta_2.setProgress(delta);
                                    sb_kb_attr_setting_pop_shot_help_time_2.setProgress(time);
                                    tv_kb_attr_setting_pop_shot_help_delta_value_3.setText(String.valueOf(delta));
                                    tv_kb_attr_setting_pop_shot_help_time_value_3.setText(String.valueOf(time));
                                    sb_kb_attr_setting_pop_shot_help_delta_3.setProgress(delta);
                                    sb_kb_attr_setting_pop_shot_help_time_3.setProgress(time);
                                    tv_kb_attr_setting_pop_shot_help_delta_value_4.setText(String.valueOf(delta));
                                    tv_kb_attr_setting_pop_shot_help_time_value_4.setText(String.valueOf(time));
                                    sb_kb_attr_setting_pop_shot_help_delta_4.setProgress(delta);
                                    sb_kb_attr_setting_pop_shot_help_time_4.setProgress(time);
                                    rb_kb_attr_setting_pop_shot_help_setting.setChecked(true);
                                    kb_attr_setting_pop_shot_help_setting.setBackgroundColor(Color.rgb(0x80, 0xe0, 0xe0));
                                }
                            } else {
                                int delta = (tempAttrEvTbl[tempAttrTbl[k][1]] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 1];
                                int time = MAX_SHOT_HELP_TIME + 1 - ((tempAttrEvTbl[tempAttrTbl[k][1] + 2] << 8) | tempAttrEvTbl[tempAttrTbl[k][1] + 3]);
                                tv_kb_attr_setting_pop_shot_help_delta_value.setText(String.valueOf(delta));
                                tv_kb_attr_setting_pop_shot_help_time_value.setText(String.valueOf(time));
                                sb_kb_attr_setting_pop_shot_help_delta.setProgress(delta);
                                sb_kb_attr_setting_pop_shot_help_time.setProgress(time);
                            }
                        } else if ((tempAttrTbl[k][0] == Transfer_Con.ATTR_MULTI_POSITION) && mGlobalVar.getIsSupportKeySplit_KB()) {
                            int a = tempAttrEvTbl[tempAttrTbl[k][1]];
                            rb_multi_button.setChecked(true);
                            item_kb_attr_setting_pop_multi.setVisibility(View.VISIBLE);
                            kb_attr_setting_pop_button_split_layout.setVisibility(View.VISIBLE);
                            item_kb_attr_setting_pop_multi.setValue(a);
                        } else if ((tempAttrTbl[k][0] == Transfer_Con.ATTR_MACRO) && (Transfer_Con.ENABLE_SUPPORT_MACRO)) {
                            kb_attr_setting_pop_macro_btn_layout.setVisibility(View.VISIBLE);
                            if ((tempAttrEvTbl[tempAttrTbl[k][1]] & 0x80) == 0x80)
                                rb_kb_attr_setting_pop_macro_up.setChecked(true);
                            else if ((tempAttrEvTbl[tempAttrTbl[k][1]] & 0x40) == 0x40)
                                rb_kb_attr_setting_pop_macro_loop.setChecked(true);
                            else
                                rb_kb_attr_setting_pop_macro_down.setChecked(true);

                            //sb_kb_attr_setting_pop_macro_time.setProgress(200);
                            //tv_kb_attr_setting_pop_macro_time_value.setText(String.valueOf(sb_kb_attr_setting_pop_macro_time.getProgress()));
                            tv_kb_attr_setting_pop_macro_desc.setText(parseAutoEvent(k));
                            System.arraycopy(tempAttrEvTbl, tempAttrTbl[k][1], tempAttrEvTblEdit, 0, tempAttrTbl[k][2]);
                            tempAttrTblEdit[0] = tempAttrTbl[k][0];
                            tempAttrTblEdit[1] = tempAttrTbl[k][1];
                            tempAttrTblEdit[2] = tempAttrTbl[k][2];
                            g_mAutoEventTblLen = tempAttrTbl[k][2];
                            rb_macro_btn.setChecked(true);
                        } else if ((tempAttrTbl[k][0] >= Transfer_Con.ATTR_QUICK_ONOFF) && (tempAttrTbl[k][0] <= Transfer_Con.ATTR_QUICK_SW_WITH_BTN_OFF) && Transfer_Con.ENABLE_SPECIAL_KEY_ATTR) {
                            int a;
                            kb_attr_setting_pop_left_layout.setVisibility(View.GONE);
                            for (a = 4; a < mGlobalVar.getDirectCenterIndex(); a++) {
                                if ((a > 0x63) && (a < 0x80))
                                    continue;
                                else if(mGlobalVar.switchMouseToKeyEvent((mGlobalVar.getSwitchToMouseKey_KB()&0xff00)>>8,mGlobalVar.getSwitchToMouseKey_KB()&0xff)==a)
                                    continue;
                                if (tempAttrTbl[a][0] == Transfer_Con.bFPSPullGunDown)
                                    break;
                            }
                            kb_attr_setting_pop_special_attr_layout.setVisibility(View.VISIBLE);
                            TypedArray ar = getResources().obtainTypedArray(R.array.mp1_button_images);
                            int ivId = ar.getResourceId(a, 0);
                            iv_kb_attr_setting_pop_special_attr_shot_help.setImageResource(ivId);
                            ar.recycle();
                        }
                        else if (tempAttrTbl[k][0] == Transfer_Con.ATTR_QUICK_SWITCH_MOUSE) {
                            kb_attr_setting_pop_mouse_relation_layout.setVisibility(View.VISIBLE);
                            rb_kb_attr_setting_pop_mouse_relation.setChecked(true);
                            rb_kb_attr_setting_pop_mouse_relation_bag.setChecked(true);
                            if(mGlobalVar.get_IntVersion()>=((1<<24)+(1<<8)+35))
                                rb_kb_attr_setting_pop_mouse_relation_null.setVisibility(View.VISIBLE);
                        }
                        else if (tempAttrTbl[k][0] == Transfer_Con.ATTR_QUICK_SWITCH_MOUSE_1) {
                            kb_attr_setting_pop_mouse_relation_layout.setVisibility(View.VISIBLE);
                            rb_kb_attr_setting_pop_mouse_relation.setChecked(true);
                            rb_kb_attr_setting_pop_mouse_relation_null.setChecked(true);
                            if(mGlobalVar.get_IntVersion()>=((1<<24)+(1<<8)+35))
                                rb_kb_attr_setting_pop_mouse_relation_null.setVisibility(View.VISIBLE);
                        }
                        else {
                            if (!Transfer_Con.DISABLE_RESET_VIEW) {
                                if ((tempAttrTbl[k][0] == Transfer_Con.ATTR_RESET_VIEW)) {
                                    rb_kb_attr_setting_reset_view_on.setChecked(true);
                                } else {
                                    rb_kb_attr_setting_reset_view_off.setChecked(true);
                                }
                                kb_attr_setting_pop_reset_view_layout.setVisibility(View.VISIBLE);
                            }
                            rb_normal.setChecked(true);
                            rb_direct.setChecked(false);
                            rb_full.setChecked(true);
                            rb_continue_tap.setChecked(false);
                        }
                        if (Transfer_Con.ENABLE_SHOT_HELP_POSTURE) {
                            if (mGlobalVar.getIsSupportShotHelpPosture_KB()) {
                                final LinearLayout kb_attr_setting_pop_select_layout = view.findViewById(R.id.kb_attr_setting_pop_select_layout);
                                GridView gv_kb_attr_setting_pop_select = view.findViewById(R.id.gv_kb_attr_setting_pop_select);
                                final List<Map<String, Object>> data_list;
                                SimpleAdapter sim_adapter;

                                data_list = new ArrayList<Map<String, Object>>();
                                iv_shot_help = new ImageView[MAX_USER_SET_KEY_NUM];
                                TypedArray ar = getResources().obtainTypedArray(R.array.mp1_button_images);
                                int len = ar.length();
                                int[] resIds = new int[len];

                                for (int a = 4; a < mGlobalVar.getDirectCenterIndex(); a++) {
                                    boolean flag = true;
                                    if ((a > 0x63) && (a < 0x80))
                                        continue;
                                    else if(mGlobalVar.switchMouseToKeyEvent((mGlobalVar.getSwitchToMouseKey_KB()&0xff00)>>8,mGlobalVar.getSwitchToMouseKey_KB()&0xff)==a)
                                        continue;
                                    
                                    if ((tempAttrTbl[a][0] != 0x00) && ((tempAttrTbl[a][0]&0xff) != 0xff))
                                        continue;

                                    for (int s = 0; s < MAX_USER_SET_KEY_NUM; s++) {
                                        if (mShotHelpImageIndex[s] == a) {
                                            flag = false;
                                            break;
                                        }
                                    }
                                    if (!flag)
                                        continue;
                                    Map<String, Object> map = new HashMap<String, Object>();
                                    resIds[a] = ar.getResourceId(a, 0);
                                    map.put("image", resIds[a]);
                                    map.put("id", a);
                                    data_list.add(map);
                                }


                                String[] from = {"image"};
                                int[] to = {R.id.iv_kb_gv};
                                sim_adapter = new SimpleAdapter(FloatMenuService_New.this, data_list, R.layout.kb_function_select_gv_content, from, to);
                                gv_kb_attr_setting_pop_select.setAdapter(sim_adapter);
                                gv_kb_attr_setting_pop_select.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                                    @Override
                                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                        kb_attr_setting_pop_select_layout.setVisibility(View.GONE);
                                        mShotHelpImageIndex[mShotHelpImageSelectIndex] = getItemID(data_list, position);
                                        TypedArray ar = getResources().obtainTypedArray(R.array.mp1_button_images);
                                        int len = ar.length();
                                        int[] resIds = new int[len];
                                        resIds[mShotHelpImageIndex[mShotHelpImageSelectIndex]] = ar.getResourceId(mShotHelpImageIndex[mShotHelpImageSelectIndex], 0);
                                        iv_shot_help[mShotHelpImageSelectIndex].setImageResource(resIds[mShotHelpImageIndex[mShotHelpImageSelectIndex] & 0xFF]);
                                        ar.recycle();
                                    }
                                });

                                iv_shot_help[0] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting1);
                                iv_shot_help[1] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting2);
                                iv_shot_help[2] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting3);
                                iv_shot_help[3] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting4);
                                iv_shot_help[4] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting_off);
                                iv_shot_help[5] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting_crouch);
                                iv_shot_help[6] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting_lie_down);
                                iv_shot_help[7] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting_standing);
                                iv_shot_help[8] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting_trigger);
                                iv_shot_help[9] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting_off_1);
                                iv_shot_help[10] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting1_sw);
                                iv_shot_help[11] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting2_sw);
                                iv_shot_help[12] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting3_sw);
                                iv_shot_help[13] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting4_sw);
                                iv_shot_help[14] = view.findViewById(R.id.iv_kb_attr_setting_pop_shot_help_setting_switch_params);
                                for (int a = 0; a < MAX_USER_SET_KEY_NUM; a++) {
                                    final int index = a;
                                    resIds[mShotHelpImageIndex[a]] = ar.getResourceId(mShotHelpImageIndex[a], 0);
                                    iv_shot_help[a].setImageResource(resIds[mShotHelpImageIndex[a]]);
                                    iv_shot_help[a].setOnClickListener(new View.OnClickListener() {
                                        @Override
                                        public void onClick(View v) {
                                            kb_attr_setting_pop_select_layout.setVisibility(View.VISIBLE);
                                            mShotHelpImageSelectIndex = index;
                                        }
                                    });
                                }
                                ar.recycle();

                            }
                        }
                        builder.setView(view);
                        builder.setTitle(getResources().getString(R.string.str_global_advanced_setting))
                                .setIcon(img_id)
                                .setPositiveButton(getResources().getString(R.string.string_pop_confirm), new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        if (rb_direct.isChecked()) {
                                            if (mGlobalVar.curPkgName.contains(Transfer_Con.defPackageName[1])) {
                                                tempAttrTbl[k][0] = Transfer_Con.bSkillWithDirect;
                                            } else {
                                                tempAttrTbl[k][0] = Transfer_Con.ATTR_VIEW_MOVE;
                                            }
                                            if (rb_full.isChecked()) {
                                                tempAttrTbl[k][1] = 0xffff;
                                                tempAttrTbl[k][2] = 0xffff;
                                            } else {
                                                tempAttrTbl[k][1] = 5000;
                                                tempAttrTbl[k][2] = 0xffff;
                                            }
                                        } else if (rb_continue_tap.isChecked()) {
                                            tempAttrTbl[k][0] = Transfer_Con.bContinueClick;
                                            tempAttrTbl[k][1] = 0xffff;
                                            tempAttrTbl[k][2] = sb_kb_attr_setting_pop_tap_time.getProgress();
                                        } else if (rb_get_down.isChecked()) {
                                            tempAttrTbl[k][0] = Transfer_Con.ATTR_GET_DOWN;
                                            tempAttrTbl[k][1] = 0xffff;
                                            tempAttrTbl[k][2] = 0xffff;
                                        } else if (rb_shot_help.isChecked()) {
                                            if (mGlobalVar.getIsSupportMultiShotHelp_KB()) {
                                                tempAttrTblEdit[0] = Transfer_Con.bFPSPullGunDown;

                                                if(mGlobalVar.getIsSupportShptHelpInsert_KB())
                                                {
                                                    g_mAutoEventTblLen = 21;
                                                    tempAttrEvTblEdit[16] = (sb_kb_attr_setting_pop_shot_help_delta_4.getProgress() >> 8) & 0xff;
                                                    tempAttrEvTblEdit[17] = (sb_kb_attr_setting_pop_shot_help_delta_4.getProgress()) & 0xff;
                                                    tempAttrEvTblEdit[18] = ((MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time_4.getProgress()) >> 8) & 0xff;
                                                    tempAttrEvTblEdit[19] = (MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time_4.getProgress()) & 0xff;
                                                    tempAttrEvTblEdit[20] = 0;
                                                }
                                                else {
                                                    g_mAutoEventTblLen = 17;
                                                    if (rb_kb_attr_setting_pop_shot_help_setting_1.isChecked())
                                                        tempAttrEvTblEdit[16] = 1;
                                                    else if (rb_kb_attr_setting_pop_shot_help_setting_2.isChecked())
                                                        tempAttrEvTblEdit[16] = 2;
                                                    else if (rb_kb_attr_setting_pop_shot_help_setting_3.isChecked())
                                                        tempAttrEvTblEdit[16] = 3;
                                                    else
                                                        tempAttrEvTblEdit[16] = 0;
                                                }
                                                tempAttrEvTblEdit[0] = (sb_kb_attr_setting_pop_shot_help_delta.getProgress() >> 8) & 0xff;
                                                tempAttrEvTblEdit[1] = (sb_kb_attr_setting_pop_shot_help_delta.getProgress()) & 0xff;
                                                tempAttrEvTblEdit[2] = ((MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time.getProgress()) >> 8) & 0xff;
                                                tempAttrEvTblEdit[3] = (MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time.getProgress()) & 0xff;
                                                tempAttrEvTblEdit[4] = (sb_kb_attr_setting_pop_shot_help_delta_1.getProgress() >> 8) & 0xff;
                                                tempAttrEvTblEdit[5] = (sb_kb_attr_setting_pop_shot_help_delta_1.getProgress()) & 0xff;
                                                tempAttrEvTblEdit[6] = ((MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time_1.getProgress()) >> 8) & 0xff;
                                                tempAttrEvTblEdit[7] = (MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time_1.getProgress()) & 0xff;
                                                tempAttrEvTblEdit[8] = (sb_kb_attr_setting_pop_shot_help_delta_2.getProgress() >> 8) & 0xff;
                                                tempAttrEvTblEdit[9] = (sb_kb_attr_setting_pop_shot_help_delta_2.getProgress()) & 0xff;
                                                tempAttrEvTblEdit[10] = ((MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time_2.getProgress()) >> 8) & 0xff;
                                                tempAttrEvTblEdit[11] = (MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time_2.getProgress()) & 0xff;
                                                tempAttrEvTblEdit[12] = (sb_kb_attr_setting_pop_shot_help_delta_3.getProgress() >> 8) & 0xff;
                                                tempAttrEvTblEdit[13] = (sb_kb_attr_setting_pop_shot_help_delta_3.getProgress()) & 0xff;
                                                tempAttrEvTblEdit[14] = ((MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time_3.getProgress()) >> 8) & 0xff;
                                                tempAttrEvTblEdit[15] = (MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time_3.getProgress()) & 0xff;

                                                submit_tempAttrEvTable(k);

                                            /*

                                            if (Transfer_Con.ENABLE_F5_FOR_SHOT_HELP_ON_OFF) {
                                                tempAttrTbl[0x3A][0] = 0x30;
                                                tempAttrTbl[0x3A][1] = 0xFFFF;
                                                tempAttrTbl[0x3A][2] = Transfer_Con.bFPSPullGunDown;
                                            }
                                            tempAttrTbl[0x3B][0] = 0x31;
                                            tempAttrTbl[0x3B][1] = 0xFFFF;
                                            tempAttrTbl[0x3B][2] = 0;

                                            tempAttrTbl[0x3C][0] = 0x31;
                                            tempAttrTbl[0x3C][1] = 0xFFFF;
                                            tempAttrTbl[0x3C][2] = 1;

                                            tempAttrTbl[0x3D][0] = 0x31;
                                            tempAttrTbl[0x3D][1] = 0xFFFF;
                                            tempAttrTbl[0x3D][2] = 2;

                                            tempAttrTbl[0x3E][0] = 0x31;
                                            tempAttrTbl[0x3E][1] = 0xFFFF;
                                            tempAttrTbl[0x3E][2] = 3;

                                             */
                                                tempAttrTbl[mShotHelpImageIndex[9]][0] = Transfer_Con.ATTR_QUICK_ONOFF;
                                                tempAttrTbl[mShotHelpImageIndex[9]][1] = 0xFFFF;
                                                tempAttrTbl[mShotHelpImageIndex[9]][2] = Transfer_Con.bFPSPullGunDown;
                                                if (mShotHelpImageIndexBackup[9] != mShotHelpImageIndex[9]) {
                                                    tempAttrTbl[mShotHelpImageIndexBackup[9]][0] = 0xFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[9]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[9]][2] = 0xFFFF;
                                                }

                                                tempAttrTbl[mShotHelpImageIndex[10]][0] = Transfer_Con.ATTR_QUICK_SWITCH;
                                                tempAttrTbl[mShotHelpImageIndex[10]][1] = 0xFFFF;
                                                tempAttrTbl[mShotHelpImageIndex[10]][2] = 0;
                                                if (mShotHelpImageIndexBackup[10] != mShotHelpImageIndex[10]) {
                                                    tempAttrTbl[mShotHelpImageIndexBackup[10]][0] = 0xFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[10]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[10]][2] = 0xFFFF;
                                                }

                                                tempAttrTbl[mShotHelpImageIndex[11]][0] = Transfer_Con.ATTR_QUICK_SWITCH;
                                                tempAttrTbl[mShotHelpImageIndex[11]][1] = 0xFFFF;
                                                tempAttrTbl[mShotHelpImageIndex[11]][2] = 1;
                                                if (mShotHelpImageIndexBackup[11] != mShotHelpImageIndex[11]) {
                                                    tempAttrTbl[mShotHelpImageIndexBackup[11]][0] = 0xFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[11]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[11]][2] = 0xFFFF;
                                                }

                                                tempAttrTbl[mShotHelpImageIndex[12]][0] = Transfer_Con.ATTR_QUICK_SWITCH;
                                                tempAttrTbl[mShotHelpImageIndex[12]][1] = 0xFFFF;
                                                tempAttrTbl[mShotHelpImageIndex[12]][2] = 2;
                                                if (mShotHelpImageIndexBackup[12] != mShotHelpImageIndex[12]) {
                                                    tempAttrTbl[mShotHelpImageIndexBackup[12]][0] = 0xFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[12]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[12]][2] = 0xFFFF;
                                                }

                                                tempAttrTbl[mShotHelpImageIndex[13]][0] = Transfer_Con.ATTR_QUICK_SWITCH;
                                                tempAttrTbl[mShotHelpImageIndex[13]][1] = 0xFFFF;
                                                tempAttrTbl[mShotHelpImageIndex[13]][2] = 3;
                                                if (mShotHelpImageIndexBackup[13] != mShotHelpImageIndex[13]) {
                                                    tempAttrTbl[mShotHelpImageIndexBackup[13]][0] = 0xFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[13]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[13]][2] = 0xFFFF;
                                                }

                                                if (cb_kb_attr_setting_pop_shot_help_setting_off.isChecked()) {
                                                    tempAttrTbl[mShotHelpImageIndex[4]][0] = Transfer_Con.ATTR_QUICK_ONOFF_WITH_BTN;
                                                    tempAttrTbl[mShotHelpImageIndex[4]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndex[4]][2] = Transfer_Con.bFPSPullGunDown;
                                                } else {
                                                    if ((tempCoordinateTbl[mShotHelpImageIndex[4] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[4] * 2 + 1] == 32768)) {
                                                        tempAttrTbl[mShotHelpImageIndex[4]][0] = 0xFF;
                                                    } else {
                                                        tempAttrTbl[mShotHelpImageIndex[4]][0] = 0x00;
                                                    }
                                                    tempAttrTbl[mShotHelpImageIndex[4]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndex[4]][2] = 0xFFFF;
                                                }
                                                if (mShotHelpImageIndexBackup[4] != mShotHelpImageIndex[4]) {
                                                    if ((tempCoordinateTbl[mShotHelpImageIndexBackup[4] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[4] * 2 + 1] == 32768)) {
                                                        tempAttrTbl[mShotHelpImageIndexBackup[4]][0] = 0xFF;
                                                    } else {
                                                        tempAttrTbl[mShotHelpImageIndexBackup[4]][0] = 0x00;
                                                    }
                                                    tempAttrTbl[mShotHelpImageIndexBackup[4]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[4]][2] = 0xFFFF;
                                                }
                                                if (cb_kb_attr_setting_pop_shot_help_setting_crouch.isChecked()) {
                                                    tempAttrTbl[mShotHelpImageIndex[5]][0] = Transfer_Con.ATTR_QUICK_SWITCH_POSTURE;
                                                    tempAttrTbl[mShotHelpImageIndex[5]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndex[5]][2] = 75;
                                                } else {
                                                    if ((tempCoordinateTbl[mShotHelpImageIndex[5] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[5] * 2 + 1] == 32768)) {
                                                        tempAttrTbl[mShotHelpImageIndex[5]][0] = 0xFF;
                                                    } else {
                                                        tempAttrTbl[mShotHelpImageIndex[5]][0] = 0x00;
                                                    }
                                                    tempAttrTbl[mShotHelpImageIndex[5]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndex[5]][2] = 0xFFFF;
                                                }
                                                if (mShotHelpImageIndexBackup[5] != mShotHelpImageIndex[5]) {
                                                    if ((tempCoordinateTbl[mShotHelpImageIndexBackup[5] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[5] * 2 + 1] == 32768)) {
                                                        tempAttrTbl[mShotHelpImageIndexBackup[5]][0] = 0xFF;
                                                    } else {
                                                        tempAttrTbl[mShotHelpImageIndexBackup[5]][0] = 0x00;
                                                    }
                                                    tempAttrTbl[mShotHelpImageIndexBackup[5]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[5]][2] = 0xFFFF;
                                                }
                                                if (cb_kb_attr_setting_pop_shot_help_setting_lie_down.isChecked()) {
                                                    tempAttrTbl[mShotHelpImageIndex[6]][0] = Transfer_Con.ATTR_QUICK_SWITCH_POSTURE;
                                                    tempAttrTbl[mShotHelpImageIndex[6]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndex[6]][2] = 50;
                                                } else {
                                                    if ((tempCoordinateTbl[mShotHelpImageIndex[6] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[6] * 2 + 1] == 32768)) {
                                                        tempAttrTbl[mShotHelpImageIndex[6]][0] = 0xFF;
                                                    } else {
                                                        tempAttrTbl[mShotHelpImageIndex[6]][0] = 0x00;
                                                    }
                                                    tempAttrTbl[mShotHelpImageIndex[6]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndex[6]][2] = 0xFFFF;
                                                }
                                                if (mShotHelpImageIndexBackup[6] != mShotHelpImageIndex[6]) {
                                                    if ((tempCoordinateTbl[mShotHelpImageIndexBackup[6] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[6] * 2 + 1] == 32768)) {
                                                        tempAttrTbl[mShotHelpImageIndexBackup[6]][0] = 0xFF;
                                                    } else {
                                                        tempAttrTbl[mShotHelpImageIndexBackup[6]][0] = 0x00;
                                                    }
                                                    tempAttrTbl[mShotHelpImageIndexBackup[6]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[6]][2] = 0xFFFF;
                                                }
                                                if (cb_kb_attr_setting_pop_shot_help_setting_standing.isChecked()) {
                                                    tempAttrTbl[mShotHelpImageIndex[7]][0] = Transfer_Con.ATTR_QUICK_SWITCH_POSTURE;
                                                    tempAttrTbl[mShotHelpImageIndex[7]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndex[7]][2] = 100;
                                                } else {
                                                    if ((tempCoordinateTbl[mShotHelpImageIndex[7] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[7] * 2 + 1] == 32768)) {
                                                        tempAttrTbl[mShotHelpImageIndex[7]][0] = 0xFF;
                                                    } else {
                                                        tempAttrTbl[mShotHelpImageIndex[7]][0] = 0x00;
                                                    }
                                                    tempAttrTbl[mShotHelpImageIndex[7]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndex[7]][2] = 0xFFFF;
                                                }
                                                if (mShotHelpImageIndexBackup[7] != mShotHelpImageIndex[7]) {
                                                    if ((tempCoordinateTbl[mShotHelpImageIndexBackup[7] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[7] * 2 + 1] == 32768)) {
                                                        tempAttrTbl[mShotHelpImageIndexBackup[7]][0] = 0xFF;
                                                    } else {
                                                        tempAttrTbl[mShotHelpImageIndexBackup[7]][0] = 0x00;
                                                    }
                                                    tempAttrTbl[mShotHelpImageIndexBackup[7]][1] = 0xFFFF;
                                                    tempAttrTbl[mShotHelpImageIndexBackup[7]][2] = 0xFFFF;
                                                }


                                                if (mGlobalVar.getIsSupportShotHelpPosture_KB()) {
                                                    if (cb_kb_attr_setting_pop_shot_help_setting_trigger.isChecked()) {
                                                        if(rb_kb_attr_setting_pop_shot_help_setting_click.isChecked()||rb_kb_attr_setting_pop_shot_help_setting_click_on.isChecked())
                                                        {
                                                            if (cb_kb_attr_setting_pop_shot_help_setting.isChecked()) {
                                                                tempAttrTbl[mShotHelpImageIndex[0]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN_OFF;
                                                                tempAttrTbl[mShotHelpImageIndex[0]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[0]][2] = 0;
                                                            } else {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndex[0] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[0] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndex[0]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndex[0]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndex[0]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[0]][2] = 0xFFFF;
                                                            }
                                                            if (mShotHelpImageIndexBackup[0] != mShotHelpImageIndex[0]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[0] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[0] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[0]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[0]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[0]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[0]][2] = 0xFFFF;
                                                            }

                                                            if (cb_kb_attr_setting_pop_shot_help_setting_1.isChecked()) {
                                                                tempAttrTbl[mShotHelpImageIndex[1]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN_OFF;
                                                                tempAttrTbl[mShotHelpImageIndex[1]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[1]][2] = 1;
                                                            } else {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndex[1] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[1] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndex[1]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndex[1]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndex[1]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[1]][2] = 0xFFFF;
                                                            }

                                                            if (mShotHelpImageIndexBackup[1] != mShotHelpImageIndex[1]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[1] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[1] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[1]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[1]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[1]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[1]][2] = 0xFFFF;
                                                            }


                                                            if (cb_kb_attr_setting_pop_shot_help_setting_2.isChecked()) {
                                                                tempAttrTbl[mShotHelpImageIndex[2]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN_OFF;
                                                                tempAttrTbl[mShotHelpImageIndex[2]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[2]][2] = 2;
                                                            } else {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndex[2] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[2] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndex[2]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndex[2]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndex[2]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[2]][2] = 0xFFFF;
                                                            }
                                                            if (mShotHelpImageIndexBackup[2] != mShotHelpImageIndex[2]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[2] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[2] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[2]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[2]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[2]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[2]][2] = 0xFFFF;
                                                            }

                                                            if (cb_kb_attr_setting_pop_shot_help_setting_3.isChecked()) {
                                                                tempAttrTbl[mShotHelpImageIndex[3]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN_OFF;
                                                                tempAttrTbl[mShotHelpImageIndex[3]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[3]][2] = 3;
                                                            } else {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndex[3] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[3] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndex[3]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndex[3]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndex[3]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[3]][2] = 0xFFFF;
                                                            }
                                                            if (mShotHelpImageIndexBackup[3] != mShotHelpImageIndex[3]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[3] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[3] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[3]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[3]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[3]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[3]][2] = 0xFFFF;
                                                            }


                                                            if(rb_kb_attr_setting_pop_shot_help_setting_click_on.isChecked())
                                                                tempAttrTbl[mShotHelpImageIndex[8]][0] = Transfer_Con.ATTR_QUICK_TONGLE_ON;
                                                            else
                                                                tempAttrTbl[mShotHelpImageIndex[8]][0] = Transfer_Con.ATTR_QUICK_TONGLE_ONOFF;

                                                            tempAttrTbl[mShotHelpImageIndex[8]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[8]][2] = Transfer_Con.bFPSPullGunDown;

                                                            if (mShotHelpImageIndexBackup[8] != mShotHelpImageIndex[8]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[8] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[8] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[8]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[8]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[8]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[8]][2] = 0xFFFF;
                                                            }
                                                        }
                                                        else {
                                                            if (cb_kb_attr_setting_pop_shot_help_setting.isChecked()) {
                                                                tempAttrTbl[mShotHelpImageIndex[0]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN_1;
                                                                tempAttrTbl[mShotHelpImageIndex[0]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[0]][2] = 0;
                                                            } else {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndex[0] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[0] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndex[0]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndex[0]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndex[0]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[0]][2] = 0xFFFF;
                                                            }
                                                            if (mShotHelpImageIndexBackup[0] != mShotHelpImageIndex[0]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[0] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[0] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[0]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[0]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[0]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[0]][2] = 0xFFFF;
                                                            }

                                                            if (cb_kb_attr_setting_pop_shot_help_setting_1.isChecked()) {
                                                                tempAttrTbl[mShotHelpImageIndex[1]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN_1;
                                                                tempAttrTbl[mShotHelpImageIndex[1]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[1]][2] = 1;
                                                            } else {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndex[1] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[1] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndex[1]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndex[1]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndex[1]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[1]][2] = 0xFFFF;
                                                            }

                                                            if (mShotHelpImageIndexBackup[1] != mShotHelpImageIndex[1]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[1] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[1] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[1]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[1]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[1]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[1]][2] = 0xFFFF;
                                                            }


                                                            if (cb_kb_attr_setting_pop_shot_help_setting_2.isChecked()) {
                                                                tempAttrTbl[mShotHelpImageIndex[2]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN_1;
                                                                tempAttrTbl[mShotHelpImageIndex[2]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[2]][2] = 2;
                                                            } else {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndex[2] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[2] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndex[2]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndex[2]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndex[2]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[2]][2] = 0xFFFF;
                                                            }
                                                            if (mShotHelpImageIndexBackup[2] != mShotHelpImageIndex[2]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[2] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[2] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[2]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[2]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[2]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[2]][2] = 0xFFFF;
                                                            }

                                                            if (cb_kb_attr_setting_pop_shot_help_setting_3.isChecked()) {
                                                                tempAttrTbl[mShotHelpImageIndex[3]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN_1;
                                                                tempAttrTbl[mShotHelpImageIndex[3]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[3]][2] = 3;
                                                            } else {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndex[3] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[3] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndex[3]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndex[3]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndex[3]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndex[3]][2] = 0xFFFF;
                                                            }
                                                            if (mShotHelpImageIndexBackup[3] != mShotHelpImageIndex[3]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[3] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[3] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[3]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[3]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[3]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[3]][2] = 0xFFFF;
                                                            }

                                                            tempAttrTbl[mShotHelpImageIndex[8]][0] = Transfer_Con.ATTR_QUICK_ON_WHEN_PRESS;

                                                            tempAttrTbl[mShotHelpImageIndex[8]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[8]][2] = Transfer_Con.bFPSPullGunDown;

                                                            if (mShotHelpImageIndexBackup[8] != mShotHelpImageIndex[8]) {
                                                                if ((tempCoordinateTbl[mShotHelpImageIndexBackup[8] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[8] * 2 + 1] == 32768)) {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[8]][0] = 0xFF;
                                                                } else {
                                                                    tempAttrTbl[mShotHelpImageIndexBackup[8]][0] = 0x00;
                                                                }
                                                                tempAttrTbl[mShotHelpImageIndexBackup[8]][1] = 0xFFFF;
                                                                tempAttrTbl[mShotHelpImageIndexBackup[8]][2] = 0xFFFF;
                                                            }
                                                        }
                                                    } else {
                                                        if (cb_kb_attr_setting_pop_shot_help_setting.isChecked()) {
                                                            tempAttrTbl[mShotHelpImageIndex[0]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN;
                                                            tempAttrTbl[mShotHelpImageIndex[0]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[0]][2] = 0;
                                                        } else {
                                                            if ((tempCoordinateTbl[mShotHelpImageIndex[0] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[0] * 2 + 1] == 32768)) {
                                                                tempAttrTbl[mShotHelpImageIndex[0]][0] = 0xFF;
                                                            } else {
                                                                tempAttrTbl[mShotHelpImageIndex[0]][0] = 0x00;
                                                            }
                                                            tempAttrTbl[mShotHelpImageIndex[0]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[0]][2] = 0xFFFF;
                                                        }
                                                        if (mShotHelpImageIndexBackup[0] != mShotHelpImageIndex[0]) {
                                                            if ((tempCoordinateTbl[mShotHelpImageIndexBackup[0] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[0] * 2 + 1] == 32768)) {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[0]][0] = 0xFF;
                                                            } else {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[0]][0] = 0x00;
                                                            }
                                                            tempAttrTbl[mShotHelpImageIndexBackup[0]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndexBackup[0]][2] = 0xFFFF;
                                                        }
                                                        if (cb_kb_attr_setting_pop_shot_help_setting_1.isChecked()) {
                                                            tempAttrTbl[mShotHelpImageIndex[1]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN;
                                                            tempAttrTbl[mShotHelpImageIndex[1]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[1]][2] = 1;
                                                        } else {
                                                            if ((tempCoordinateTbl[mShotHelpImageIndex[1] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[1] * 2 + 1] == 32768)) {
                                                                tempAttrTbl[mShotHelpImageIndex[1]][0] = 0xFF;
                                                            } else {
                                                                tempAttrTbl[mShotHelpImageIndex[1]][0] = 0x00;
                                                            }
                                                            tempAttrTbl[mShotHelpImageIndex[1]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[1]][2] = 0xFFFF;
                                                        }

                                                        if (mShotHelpImageIndexBackup[1] != mShotHelpImageIndex[1]) {
                                                            if ((tempCoordinateTbl[mShotHelpImageIndexBackup[1] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[1] * 2 + 1] == 32768)) {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[1]][0] = 0xFF;
                                                            } else {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[1]][0] = 0x00;
                                                            }
                                                            tempAttrTbl[mShotHelpImageIndexBackup[1]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndexBackup[1]][2] = 0xFFFF;
                                                        }


                                                        if (cb_kb_attr_setting_pop_shot_help_setting_2.isChecked()) {
                                                            tempAttrTbl[mShotHelpImageIndex[2]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN;
                                                            tempAttrTbl[mShotHelpImageIndex[2]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[2]][2] = 2;
                                                        } else {
                                                            if ((tempCoordinateTbl[mShotHelpImageIndex[2] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[2] * 2 + 1] == 32768)) {
                                                                tempAttrTbl[mShotHelpImageIndex[2]][0] = 0xFF;
                                                            } else {
                                                                tempAttrTbl[mShotHelpImageIndex[2]][0] = 0x00;
                                                            }
                                                            tempAttrTbl[mShotHelpImageIndex[2]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[2]][2] = 0xFFFF;
                                                        }
                                                        if (mShotHelpImageIndexBackup[2] != mShotHelpImageIndex[2]) {
                                                            if ((tempCoordinateTbl[mShotHelpImageIndexBackup[2] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[2] * 2 + 1] == 32768)) {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[2]][0] = 0xFF;
                                                            } else {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[2]][0] = 0x00;
                                                            }
                                                            tempAttrTbl[mShotHelpImageIndexBackup[2]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndexBackup[2]][2] = 0xFFFF;
                                                        }
                                                        if (cb_kb_attr_setting_pop_shot_help_setting_3.isChecked()) {
                                                            tempAttrTbl[mShotHelpImageIndex[3]][0] = Transfer_Con.ATTR_QUICK_SW_WITH_BTN;
                                                            tempAttrTbl[mShotHelpImageIndex[3]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[3]][2] = 3;
                                                        } else {
                                                            if ((tempCoordinateTbl[mShotHelpImageIndex[3] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[3] * 2 + 1] == 32768)) {
                                                                tempAttrTbl[mShotHelpImageIndex[3]][0] = 0xFF;
                                                            } else {
                                                                tempAttrTbl[mShotHelpImageIndex[3]][0] = 0x00;
                                                            }
                                                            tempAttrTbl[mShotHelpImageIndex[3]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndex[3]][2] = 0xFFFF;
                                                        }
                                                        if (mShotHelpImageIndexBackup[3] != mShotHelpImageIndex[3]) {
                                                            if ((tempCoordinateTbl[mShotHelpImageIndexBackup[3] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[3] * 2 + 1] == 32768)) {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[3]][0] = 0xFF;
                                                            } else {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[3]][0] = 0x00;
                                                            }
                                                            tempAttrTbl[mShotHelpImageIndexBackup[3]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndexBackup[3]][2] = 0xFFFF;
                                                        }
                                                        if ((tempCoordinateTbl[mShotHelpImageIndex[8] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndex[8] * 2 + 1] == 32768)) {
                                                            tempAttrTbl[mShotHelpImageIndex[8]][0] = 0xFF;
                                                        } else {
                                                            tempAttrTbl[mShotHelpImageIndex[8]][0] = 0x00;
                                                        }
                                                        tempAttrTbl[mShotHelpImageIndex[8]][1] = 0xFFFF;
                                                        tempAttrTbl[mShotHelpImageIndex[8]][2] = 0xFFFF;

                                                        if (mShotHelpImageIndexBackup[8] != mShotHelpImageIndex[8]) {
                                                            if ((tempCoordinateTbl[mShotHelpImageIndexBackup[8] * 2] == 32768) || (tempCoordinateTbl[mShotHelpImageIndexBackup[8] * 2 + 1] == 32768)) {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[8]][0] = 0xFF;
                                                            } else {
                                                                tempAttrTbl[mShotHelpImageIndexBackup[8]][0] = 0x00;
                                                            }
                                                            tempAttrTbl[mShotHelpImageIndexBackup[8]][1] = 0xFFFF;
                                                            tempAttrTbl[mShotHelpImageIndexBackup[8]][2] = 0xFFFF;
                                                        }
                                                    }
                                                } else {
                                                    if (cb_kb_attr_setting_pop_shot_help_setting.isChecked()) {
                                                        tempAttrTbl[0x1E][0] = 0x32;
                                                        tempAttrTbl[0x1E][1] = 0xFFFF;
                                                        tempAttrTbl[0x1E][2] = 0;
                                                    } else {
                                                        tempAttrTbl[0x1E][0] = 0x00;
                                                        tempAttrTbl[0x1E][1] = 0xFFFF;
                                                        tempAttrTbl[0x1E][2] = 0xFFFF;
                                                    }

                                                    if (cb_kb_attr_setting_pop_shot_help_setting_1.isChecked()) {
                                                        tempAttrTbl[0x1F][0] = 0x32;
                                                        tempAttrTbl[0x1F][1] = 0xFFFF;
                                                        tempAttrTbl[0x1F][2] = 1;
                                                    } else {
                                                        tempAttrTbl[0x1F][0] = 0x00;
                                                        tempAttrTbl[0x1F][1] = 0xFFFF;
                                                        tempAttrTbl[0x1F][2] = 0xFFFF;
                                                    }

                                                    if (cb_kb_attr_setting_pop_shot_help_setting_off.isChecked()) {
                                                        tempAttrTbl[0x21][0] = 0x33;
                                                        tempAttrTbl[0x21][1] = 0xFFFF;
                                                        tempAttrTbl[0x21][2] = Transfer_Con.bFPSPullGunDown;
                                                    } else {
                                                        tempAttrTbl[0x21][0] = 0x00;
                                                        tempAttrTbl[0x21][1] = 0xFFFF;
                                                        tempAttrTbl[0x21][2] = 0xFFFF;
                                                    }
                                                }
                                            } else {
                                                tempAttrTblEdit[0] = Transfer_Con.bFPSPullGunDown;
                                                g_mAutoEventTblLen = 4;
                                                tempAttrEvTblEdit[0] = (sb_kb_attr_setting_pop_shot_help_delta.getProgress() >> 8) & 0xff;
                                                tempAttrEvTblEdit[1] = (sb_kb_attr_setting_pop_shot_help_delta.getProgress()) & 0xff;
                                                tempAttrEvTblEdit[2] = ((MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time.getProgress()) >> 8) & 0xff;
                                                tempAttrEvTblEdit[3] = (MAX_SHOT_HELP_TIME + 1 - sb_kb_attr_setting_pop_shot_help_time.getProgress()) & 0xff;
                                                submit_tempAttrEvTable(k);
                                                if (Transfer_Con.ENABLE_F5_FOR_SHOT_HELP_ON_OFF) {
                                                    tempAttrTbl[0x3E][0] = 0x30;
                                                    tempAttrTbl[0x3E][1] = 0xFFFF;
                                                    tempAttrTbl[0x3E][2] = Transfer_Con.bFPSPullGunDown;
                                                }
                                            }
                                        } else if (rb_multi_button.isChecked()) {
                                            int val = item_kb_attr_setting_pop_multi.getValue();
                                            int delta = mImageHalfSizeEdit * 2 * 0x7FFF / panelWidth;
                                            tempAttrTblEdit[0] = Transfer_Con.ATTR_MULTI_POSITION;
                                            tempAttrEvTblEdit[0] = val;
                                            g_mAutoEventTblLen = val * 4 + 1;
                                            for (int s = 0; s < val; s++) {
                                                tempAttrEvTblEdit[4 * s + 1] = (tempCoordinateTbl[2 * k] & 0xff00) >> 8;
                                                tempAttrEvTblEdit[4 * s + 2] = (tempCoordinateTbl[2 * k] & 0x00ff);
                                                tempAttrEvTblEdit[4 * s + 3] = ((tempCoordinateTbl[2 * k + 1] + delta * (s + 1)) & 0xff00) >> 8;
                                                tempAttrEvTblEdit[4 * s + 4] = ((tempCoordinateTbl[2 * k + 1] + delta * (s + 1)) & 0x00ff);
                                            }
                                            submit_tempAttrEvTable(k);
                                            showSplitButton();
                                        } else if (rb_macro_btn.isChecked()) {

                                            tempAttrTblEdit[0] = Transfer_Con.ATTR_MACRO;
                                            if (rb_kb_attr_setting_pop_macro_up.isChecked())
                                                tempAttrEvTblEdit[0] = 0x80;
                                            else if (rb_kb_attr_setting_pop_macro_loop.isChecked())
                                                tempAttrEvTblEdit[0] = 0x40;
                                            else
                                                tempAttrEvTblEdit[0] = 0x00;

                                            submit_tempAttrEvTable(k);
                                            bIsMacroChange = true;
                                        }
                                        else if(rb_kb_attr_setting_pop_mouse_relation.isChecked())
                                        {

                                            if(rb_kb_attr_setting_pop_mouse_relation_null.isChecked())
                                                tempAttrTbl[k][0] = Transfer_Con.ATTR_QUICK_SWITCH_MOUSE_1;
                                            else
                                                tempAttrTbl[k][0] = Transfer_Con.ATTR_QUICK_SWITCH_MOUSE;
                                            tempAttrTbl[k][1] = 0xFFFF;
                                            tempAttrTbl[k][2] = 2;
                                        }
                                        else {
                                            if (rb_kb_attr_setting_reset_view_on.isChecked()) {
                                                if (Transfer_Con.DISABLE_RESET_VIEW)
                                                    tempAttrTbl[k][0] = 0x00;
                                                else
                                                    tempAttrTbl[k][0] = Transfer_Con.ATTR_RESET_VIEW;
                                                tempAttrTbl[k][1] = 0xffff;
                                                tempAttrTbl[k][2] = 0xffff;
                                            } else {
                                                if ((tempAttrTbl[k][0] == Transfer_Con.bFPSPullGunDown) && mGlobalVar.getIsSupportKeySplit_KB()) {
                                                    if (mGlobalVar.getIsSupportMultiShotHelp_KB()) {
                                                        if (mGlobalVar.getIsSupportShotHelpPosture_KB()) {
                                                            for (int a = 4; a < mGlobalVar.getDirectCenterIndex(); a++) {
                                                                if ((a > 0x63) && (a < 0x80))
                                                                    continue;
                                                                else if(mGlobalVar.switchMouseToKeyEvent((mGlobalVar.getSwitchToMouseKey_KB()&0xff00)>>8,mGlobalVar.getSwitchToMouseKey_KB()&0xff)==a)
                                                                    continue;
                                                                if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SW_WITH_BTN) {
                                                                    tempAttrTbl[a][0] = 0x00;
                                                                    tempAttrTbl[a][1] = 0xFFFF;
                                                                    tempAttrTbl[a][2] = 0xFFFF;
                                                                } else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_ONOFF_WITH_BTN) {
                                                                    tempAttrTbl[a][0] = 0x00;
                                                                    tempAttrTbl[a][1] = 0xFFFF;
                                                                    tempAttrTbl[a][2] = 0xFFFF;
                                                                } else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SWITCH_POSTURE) {
                                                                    tempAttrTbl[a][0] = 0x00;
                                                                    tempAttrTbl[a][1] = 0xFFFF;
                                                                    tempAttrTbl[a][2] = 0xFFFF;
                                                                } else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_ON_WHEN_PRESS) {
                                                                    tempAttrTbl[a][0] = 0x00;
                                                                    tempAttrTbl[a][1] = 0xFFFF;
                                                                    tempAttrTbl[a][2] = 0xFFFF;
                                                                } else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SW_WITH_BTN_1) {
                                                                    tempAttrTbl[a][0] = 0x00;
                                                                    tempAttrTbl[a][1] = 0xFFFF;
                                                                    tempAttrTbl[a][2] = 0xFFFF;
                                                                } else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_ONOFF) {
                                                                    tempAttrTbl[a][0] = 0xFF;
                                                                    tempAttrTbl[a][1] = 0xFFFF;
                                                                    tempAttrTbl[a][2] = 0xFFFF;
                                                                } else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SWITCH) {
                                                                    tempAttrTbl[a][0] = 0xFF;
                                                                    tempAttrTbl[a][1] = 0xFFFF;
                                                                    tempAttrTbl[a][2] = 0xFFFF;
                                                                }else if (tempAttrTbl[a][0] == Transfer_Con.ATTR_QUICK_SW_WITH_BTN_OFF) {
                                                                    tempAttrTbl[a][0] = 0x00;
                                                                    tempAttrTbl[a][1] = 0xFFFF;
                                                                    tempAttrTbl[a][2] = 0xFFFF;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                tempAttrTbl[k][0] = 0x00;
                                                tempAttrTbl[k][1] = 0xffff;
                                                tempAttrTbl[k][2] = 0xffff;
                                            }
                                            showSplitButton();
                                        }
                                        bIsChanged = true;
                                    }
                                })
                                .setNegativeButton(getResources().getString(R.string.string_pop_cancel), new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                    }
                                });
                        mDialog = builder.create();
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                            if (Settings.canDrawOverlays(FloatMenuService_New.this))
                                mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
                        } else {
                            mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
                        }
                        mDialog.setCanceledOnTouchOutside(false);
                        mDialog.show();
                        if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
                            if (bIsVirtualMouseShowBackup) {
                                windowManager.addView(virtual_mouse_layout, paramsVirtualMouse);
                                bIsVirtualMouseShow = true;
                            }
                        }
                        rb_normal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (!Transfer_Con.ENABLE_NEW_USER_INTERFACE) {
                                    if (isChecked) {
                                        kb_attr_setting_pop_reset_view_layout.setVisibility(View.VISIBLE);
                                    } else {
                                        kb_attr_setting_pop_reset_view_layout.setVisibility(View.GONE);
                                    }
                                }
                            }
                        });
                        rb_direct.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked) {
                                    kb_attr_setting_pop_dir_layout.setVisibility(View.VISIBLE);
                                    if (!rb_limit.isChecked()) {
                                        rb_full.setChecked(true);
                                    }
                                } else
                                    kb_attr_setting_pop_dir_layout.setVisibility(View.GONE);
                            }
                        });
                        rb_shot_help.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked) {
                                    kb_attr_setting_pop_shot_help_layout.setVisibility(View.VISIBLE);
                                    tv_kb_attr_setting_pop_shot_help_delta_value.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_delta.getProgress()));
                                    tv_kb_attr_setting_pop_shot_help_time_value.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_time.getProgress()));
                                    rb_kb_attr_setting_pop_shot_help_setting.setChecked(true);
                                    if (mGlobalVar.getIsSupportMultiShotHelp_KB()) {
                                        kb_attr_setting_pop_shot_help_setting_1.setVisibility(View.VISIBLE);
                                        kb_attr_setting_pop_shot_help_setting_2.setVisibility(View.VISIBLE);
                                        kb_attr_setting_pop_shot_help_setting_3.setVisibility(View.VISIBLE);
                                        kb_attr_setting_pop_shot_help_setting_off.setVisibility(View.VISIBLE);
                                        kb_attr_setting_pop_shot_help_setting_layout.setVisibility(View.VISIBLE);
                                        tv_kb_attr_setting_pop_shot_help_delta_value_1.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_delta_1.getProgress()));
                                        tv_kb_attr_setting_pop_shot_help_time_value_1.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_time_1.getProgress()));
                                        tv_kb_attr_setting_pop_shot_help_delta_value_2.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_delta_2.getProgress()));
                                        tv_kb_attr_setting_pop_shot_help_time_value_2.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_time_2.getProgress()));
                                        tv_kb_attr_setting_pop_shot_help_delta_value_3.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_delta_3.getProgress()));
                                        tv_kb_attr_setting_pop_shot_help_time_value_3.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_time_3.getProgress()));
                                        if (mGlobalVar.getIsSupportShotHelpPosture_KB()) {
                                            kb_attr_setting_pop_shot_help_setting_crouch_layout.setVisibility(View.VISIBLE);
                                            kb_attr_setting_pop_shot_help_setting_lie_down_layout.setVisibility(View.VISIBLE);
                                            kb_attr_setting_pop_shot_help_setting_standing_layout.setVisibility(View.VISIBLE);
                                            if (mGlobalVar.getIsSupportShotHelpTrigger_KB()) {
                                                kb_attr_setting_pop_shot_help_setting_trigger_layout.setVisibility(View.VISIBLE);
                                                if(mGlobalVar.getIsSupportShotHelpTrigger1_KB())
                                                    rg_attr_setting_pop_shot_help_setting_on_off_layout.setVisibility(View.VISIBLE);
                                            }
                                        }
                                        if(mGlobalVar.getIsSupportShptHelpInsert_KB())
                                        {
                                            kb_attr_setting_pop_shot_help_setting_4.setVisibility(View.VISIBLE);
                                            tv_kb_attr_setting_pop_shot_help_delta_value_4.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_delta_4.getProgress()));
                                            tv_kb_attr_setting_pop_shot_help_time_value_4.setText(String.valueOf(sb_kb_attr_setting_pop_shot_help_time_4.getProgress()));
                                        }
                                        if(mGlobalVar.getIsSupportShptHelpInsertDefine_KB()) {
                                            rb_kb_attr_setting_pop_shot_help_setting_click_on.setVisibility(View.VISIBLE);
                                            kb_attr_setting_pop_shot_help_setting_switch_params_layout.setVisibility(View.VISIBLE);
                                        }
                                    }
                                } else
                                    kb_attr_setting_pop_shot_help_layout.setVisibility(View.GONE);
                            }
                        });
                        rb_multi_button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked) {
                                    item_kb_attr_setting_pop_multi.setVisibility(View.VISIBLE);
                                    kb_attr_setting_pop_button_split_layout.setVisibility(View.VISIBLE);
                                } else {
                                    item_kb_attr_setting_pop_multi.setVisibility(View.GONE);
                                    kb_attr_setting_pop_button_split_layout.setVisibility(View.GONE);
                                }
                            }
                        });
                        rb_get_down.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked)
                                    kb_attr_setting_pop_get_down_layout.setVisibility(View.VISIBLE);
                                else
                                    kb_attr_setting_pop_get_down_layout.setVisibility(View.GONE);
                            }
                        });
                        rb_continue_tap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked) {
                                    kb_attr_setting_pop_continue_tap_layout.setVisibility(View.VISIBLE);
                                    tv_kb_attr_setting_pop_tap_time_value.setText(String.valueOf(sb_kb_attr_setting_pop_tap_time.getProgress()));
                                } else
                                    kb_attr_setting_pop_continue_tap_layout.setVisibility(View.GONE);
                            }
                        });
                        rb_kb_attr_setting_pop_mouse_relation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked) {
                                    kb_attr_setting_pop_mouse_relation_layout.setVisibility(View.VISIBLE);
                                    if(mGlobalVar.get_IntVersion()>=((1<<24)+(1<<8)+35))
                                        rb_kb_attr_setting_pop_mouse_relation_null.setVisibility(View.VISIBLE);
                                }
                                else
                                    kb_attr_setting_pop_mouse_relation_layout.setVisibility(View.GONE);
                            }
                        });
                        sb_kb_attr_setting_pop_shot_help_delta.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_delta_value.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_del.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_delta.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_add.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta.getProgress();
                                if (++val > MAX_SHOT_HELP_DELTA)
                                    val = MAX_SHOT_HELP_DELTA;
                                sb_kb_attr_setting_pop_shot_help_delta.setProgress(val);
                            }
                        });
                        sb_kb_attr_setting_pop_shot_help_time.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_time_value.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_del.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_time.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_add.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time.getProgress();
                                if (++val > MAX_SHOT_HELP_TIME)
                                    val = MAX_SHOT_HELP_TIME;
                                sb_kb_attr_setting_pop_shot_help_time.setProgress(val);
                            }
                        });

                        rb_kb_attr_setting_pop_shot_help_setting.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked) {
                                    kb_attr_setting_pop_shot_help_setting.setBackgroundColor(Color.rgb(0x80, 0xe0, 0xe0));
                                    rb_kb_attr_setting_pop_shot_help_setting_3.setChecked(false);
                                    rb_kb_attr_setting_pop_shot_help_setting_1.setChecked(false);
                                    rb_kb_attr_setting_pop_shot_help_setting_2.setChecked(false);

                                    kb_attr_setting_pop_shot_help_setting_3.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                    kb_attr_setting_pop_shot_help_setting_1.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                    kb_attr_setting_pop_shot_help_setting_2.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                } else {
                                    kb_attr_setting_pop_shot_help_setting.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                }
                            }
                        });

                        // 1
                        sb_kb_attr_setting_pop_shot_help_delta_1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_delta_value_1.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_del_1.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta_1.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_delta_1.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_add_1.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta_1.getProgress();
                                if (++val > MAX_SHOT_HELP_DELTA)
                                    val = MAX_SHOT_HELP_DELTA;
                                sb_kb_attr_setting_pop_shot_help_delta_1.setProgress(val);
                            }
                        });
                        sb_kb_attr_setting_pop_shot_help_time_1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_time_value_1.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_del_1.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time_1.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_time_1.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_add_1.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time_1.getProgress();
                                if (++val > MAX_SHOT_HELP_TIME)
                                    val = MAX_SHOT_HELP_TIME;
                                sb_kb_attr_setting_pop_shot_help_time_1.setProgress(val);
                            }
                        });
                        rb_kb_attr_setting_pop_shot_help_setting_1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked) {
                                    kb_attr_setting_pop_shot_help_setting_1.setBackgroundColor(Color.rgb(0x80, 0xe0, 0xe0));
                                    rb_kb_attr_setting_pop_shot_help_setting.setChecked(false);
                                    rb_kb_attr_setting_pop_shot_help_setting_3.setChecked(false);
                                    rb_kb_attr_setting_pop_shot_help_setting_2.setChecked(false);

                                    kb_attr_setting_pop_shot_help_setting.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                    kb_attr_setting_pop_shot_help_setting_3.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                    kb_attr_setting_pop_shot_help_setting_2.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                } else {
                                    kb_attr_setting_pop_shot_help_setting_1.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                }
                            }
                        });
                        // 2
                        sb_kb_attr_setting_pop_shot_help_delta_2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_delta_value_2.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_del_2.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta_2.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_delta_2.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_add_2.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta_2.getProgress();
                                if (++val > MAX_SHOT_HELP_DELTA)
                                    val = MAX_SHOT_HELP_DELTA;
                                sb_kb_attr_setting_pop_shot_help_delta_2.setProgress(val);
                            }
                        });
                        sb_kb_attr_setting_pop_shot_help_time_2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_time_value_2.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_del_2.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time_2.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_time_2.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_add_2.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time_2.getProgress();
                                if (++val > MAX_SHOT_HELP_TIME)
                                    val = MAX_SHOT_HELP_TIME;
                                sb_kb_attr_setting_pop_shot_help_time_2.setProgress(val);
                            }
                        });
                        rb_kb_attr_setting_pop_shot_help_setting_2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked) {
                                    kb_attr_setting_pop_shot_help_setting_2.setBackgroundColor(Color.rgb(0x80, 0xe0, 0xe0));
                                    rb_kb_attr_setting_pop_shot_help_setting.setChecked(false);
                                    rb_kb_attr_setting_pop_shot_help_setting_1.setChecked(false);
                                    rb_kb_attr_setting_pop_shot_help_setting_3.setChecked(false);

                                    kb_attr_setting_pop_shot_help_setting.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                    kb_attr_setting_pop_shot_help_setting_1.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                    kb_attr_setting_pop_shot_help_setting_3.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                } else {
                                    kb_attr_setting_pop_shot_help_setting_2.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                }
                            }
                        });
                        // 3
                        sb_kb_attr_setting_pop_shot_help_delta_3.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_delta_value_3.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_del_3.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta_3.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_delta_3.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_add_3.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta_3.getProgress();
                                if (++val > MAX_SHOT_HELP_DELTA)
                                    val = MAX_SHOT_HELP_DELTA;
                                sb_kb_attr_setting_pop_shot_help_delta_3.setProgress(val);
                            }
                        });
                        sb_kb_attr_setting_pop_shot_help_time_3.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_time_value_3.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_del_3.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time_3.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_time_3.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_add_3.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time_3.getProgress();
                                if (++val > MAX_SHOT_HELP_TIME)
                                    val = MAX_SHOT_HELP_TIME;
                                sb_kb_attr_setting_pop_shot_help_time_3.setProgress(val);
                            }
                        });
                        rb_kb_attr_setting_pop_shot_help_setting_3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked) {
                                    rb_kb_attr_setting_pop_shot_help_setting.setChecked(false);
                                    rb_kb_attr_setting_pop_shot_help_setting_1.setChecked(false);
                                    rb_kb_attr_setting_pop_shot_help_setting_2.setChecked(false);

                                    kb_attr_setting_pop_shot_help_setting.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                    kb_attr_setting_pop_shot_help_setting_1.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                    kb_attr_setting_pop_shot_help_setting_2.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                    kb_attr_setting_pop_shot_help_setting_3.setBackgroundColor(Color.rgb(0x80, 0xe0, 0xe0));
                                } else {
                                    kb_attr_setting_pop_shot_help_setting_3.setBackgroundColor(Color.rgb(0xe0, 0xe0, 0xe0));
                                }
                            }
                        });

                        // 4
                        sb_kb_attr_setting_pop_shot_help_delta_4.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_delta_value_4.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_del_4.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta_4.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_delta_4.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_delta_add_4.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_delta_4.getProgress();
                                if (++val > MAX_SHOT_HELP_DELTA)
                                    val = MAX_SHOT_HELP_DELTA;
                                sb_kb_attr_setting_pop_shot_help_delta_4.setProgress(val);
                            }
                        });
                        sb_kb_attr_setting_pop_shot_help_time_4.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_shot_help_time_value_4.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_del_4.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time_4.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_shot_help_time_4.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_shot_help_time_add_4.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_shot_help_time_4.getProgress();
                                if (++val > MAX_SHOT_HELP_TIME)
                                    val = MAX_SHOT_HELP_TIME;
                                sb_kb_attr_setting_pop_shot_help_time_4.setProgress(val);
                            }
                        });
                        //

                        sb_kb_attr_setting_pop_tap_time.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_tap_time_value.setText(String.valueOf(progress));
                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {
                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                            }
                        });
                        iv_kb_attr_setting_pop_tap_time_del.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_tap_time.getProgress();
                                if (--val < 1)
                                    val = 1;
                                sb_kb_attr_setting_pop_tap_time.setProgress(val);
                            }
                        });
                        iv_kb_attr_setting_pop_tap_time_add.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                int val = sb_kb_attr_setting_pop_tap_time.getProgress();
                                if (++val > MAX_CON_TAP_TIME)
                                    val = MAX_CON_TAP_TIME;
                                sb_kb_attr_setting_pop_tap_time.setProgress(val);
                            }
                        });

                        rb_macro_btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                if (isChecked)
                                    kb_attr_setting_pop_macro_btn_layout.setVisibility(View.VISIBLE);
                                else
                                    kb_attr_setting_pop_macro_btn_layout.setVisibility(View.GONE);
                            }
                        });

                        btn_kb_attr_setting_pop_macro_rec.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                bIsMacro_record = true;
                                g_mAutoEventTblLen = 2;
                                mDialog.dismiss();
                                kb_button_setting_macro_layout.setVisibility(View.VISIBLE);
                                bIsSubViewOn = true;
                                g_mBtnMacroStep = 0;
                                tv_kb_button_setting_macro_msg.setText("");
                                if (bIsKBFloatMenuShow) {
                                    windowManager.removeView(kb_float_menu_layout);
                                    bIsKBFloatMenuShow = false;
                                }
                            }
                        });
                        btn_kb_attr_setting_pop_macro_load.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                loadAEVData(k);
                                tv_kb_attr_setting_pop_macro_desc.setText(parseTempAutoEvent());
                            }
                        });
                        btn_kb_attr_setting_pop_macro_save.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                saveAVEData(k);
                            }
                        });
                        btn_kb_attr_setting_pop_macro_edit.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
                                    if (bIsVirtualMouseShow) {
                                        windowManager.removeView(virtual_mouse_layout);
                                        bIsVirtualMouseShowBackup = true;
                                        bIsVirtualMouseShow = false;
                                    } else {
                                        bIsVirtualMouseShowBackup = false;
                                    }
                                }
                                windowManager.addView(layout_button_setting_macro_edit, paramsMacroEdit);
                                //System.arraycopy(tempAttrEvTblEdit, 0, g_u8tAutoEventTbl, (g_u8tAttrTable[g_u8ButtonID][1] & 0xFF), g_u8ActionTblLen & 0xFF);
                                if (bIsMacroChange) {
                                    //Toast.makeText(FloatMenuService_New.this,"当前",Toast.LENGTH_SHORT).show();
                                    tempAttrTblEdit_bk = tempAttrTblEdit.clone();
                                    tempAttrTblEdit_bk[2] = g_mAutoEventTblLen;
                                    System.arraycopy(tempAttrEvTblEdit, 0, tempAttrEvTblEdit_bk, 0, g_mAutoEventTblLen);
                                    bIsMacroBackup = true;
                                } else if (tempAttrTbl[k][0] == Transfer_Con.ATTR_MACRO) {
                                    g_mAutoEventTblLen = tempAttrTbl[k][2];
                                    tempAttrTblEdit[1] = tempAttrTbl[k][1];
                                    tempAttrTblEdit[2] = tempAttrTbl[k][2];
                                    System.arraycopy(tempAttrEvTbl, tempAttrTbl[k][1], tempAttrEvTblEdit, 0, g_mAutoEventTblLen);
                                    parseEvToList();
                                    myEditAdapter = new MyEditAdapter();
                                    lv_button_setting_macro_edit.setAdapter(myEditAdapter);
                                }
                                if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
                                    if (bIsVirtualMouseShowBackup) {
                                        windowManager.addView(virtual_mouse_layout, paramsVirtualMouse);
                                        bIsVirtualMouseShow = true;
                                    }
                                }
                            }
                        });

                        sb_kb_attr_setting_pop_macro_time.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                            @Override
                            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                tv_kb_attr_setting_pop_macro_time_value.setText(String.valueOf(progress));

                            }

                            @Override
                            public void onStartTrackingTouch(SeekBar seekBar) {

                            }

                            @Override
                            public void onStopTrackingTouch(SeekBar seekBar) {
                                mMacroIntervalTime = seekBar.getProgress();
                            }
                        });
                        iv_kb_attr_setting_pop_macro_time_add.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                mMacroIntervalTime = sb_kb_attr_setting_pop_macro_time.getProgress();
                                if (++mMacroIntervalTime > MAX_MACRO_INTERVAL_TIME)
                                    mMacroIntervalTime = MAX_MACRO_INTERVAL_TIME;
                                sb_kb_attr_setting_pop_macro_time.setProgress(mMacroIntervalTime);
                            }
                        });
                        iv_kb_attr_setting_pop_macro_time_del.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                mMacroIntervalTime = sb_kb_attr_setting_pop_macro_time.getProgress();
                                mMacroIntervalTime--;
                                if (mMacroIntervalTime < 1)
                                    mMacroIntervalTime = 1;
                                sb_kb_attr_setting_pop_macro_time.setProgress(mMacroIntervalTime);
                            }
                        });
                    }
                });
            }

            if (!bIsImageAlreadyCreate1) {
                iv_kb_setting_direct_edit = new ImageView(FloatMenuService_New.this);
            }
            iv_kb_setting_direct_edit.setImageResource(R.drawable.kb_direct);
            iv_kb_setting_direct_edit.setX((float) tempCoordinateTbl[mGlobalVar.getDirectCenterIndex() * 2 + 1] * panelWidth / 0x7FFF - mImageHalfSizeEdit * 3);
            iv_kb_setting_direct_edit.setY((float) tempCoordinateTbl[mGlobalVar.getDirectCenterIndex() * 2] * panelHeight / 0x7FFF - mImageHalfSizeEdit * 3);
            ViewGroup.LayoutParams lp1 = new ViewGroup.LayoutParams(mImageHalfSizeEdit * 6, mImageHalfSizeEdit * 6);
            g_ringSizeRocker = mImageHalfSizeEdit * 3 + mImgRingSize / 2;
            iv_kb_setting_direct_edit.setAlpha(((float) mGlobalVar.getPt_Tbl_View_Alpha()) / 10);
            iv_kb_setting_direct_edit.setVisibility(View.VISIBLE);
            if (!bIsImageAlreadyCreate1) {
                button_pos_edit_layout.addView(iv_kb_setting_direct_edit, lp1);
            } else {
                ViewGroup.LayoutParams params = iv_kb_setting_direct_edit.getLayoutParams();
                params.width = mImageHalfSizeEdit * 6;
                params.height = mImageHalfSizeEdit * 6;
                iv_kb_setting_direct_edit.setLayoutParams(params);
            }
            if ((tempKbTbl[0] & 0xff) != 0xff) {
                img_button_edit[tempKbTbl[0]].setX(iv_kb_setting_direct_edit.getX() + mImageHalfSizeEdit * 2);
                img_button_edit[tempKbTbl[0]].setY(iv_kb_setting_direct_edit.getY() + mImageHalfSizeEdit * 2 - mImageHalfSizeEdit * 2 + (float) mImageHalfSizeEdit / 10);
            }
            if ((tempKbTbl[1] & 0xff) != 0xff) {
                img_button_edit[tempKbTbl[1]].setX(iv_kb_setting_direct_edit.getX() + mImageHalfSizeEdit * 2);
                img_button_edit[tempKbTbl[1]].setY(iv_kb_setting_direct_edit.getY() + mImageHalfSizeEdit * 2 + mImageHalfSizeEdit * 2 - (float) mImageHalfSizeEdit / 10);
            }
            if ((tempKbTbl[2] & 0xff) != 0xff) {
                img_button_edit[tempKbTbl[2]].setX(iv_kb_setting_direct_edit.getX() + mImageHalfSizeEdit * 2 - mImageHalfSizeEdit * 2 + (float) mImageHalfSizeEdit / 10);
                img_button_edit[tempKbTbl[2]].setY(iv_kb_setting_direct_edit.getY() + mImageHalfSizeEdit * 2);
            }
            if ((tempKbTbl[3] & 0xff) != 0xff) {
                img_button_edit[tempKbTbl[3]].setX(iv_kb_setting_direct_edit.getX() + mImageHalfSizeEdit * 2 + mImageHalfSizeEdit * 2 - (float) mImageHalfSizeEdit / 10);
                img_button_edit[tempKbTbl[3]].setY(iv_kb_setting_direct_edit.getY() + mImageHalfSizeEdit * 2);
            }
            iv_kb_setting_direct_edit.setOnTouchListener(new View.OnTouchListener() {
                long[] hints = new long[2];
                int prevX = 0, prevY = 0;

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    int pos_x, pos_y;
                    boolean bIsLongPress = false;
                    switch (event.getAction()) {
                        case MotionEvent.ACTION_DOWN:
                            System.arraycopy(hints, 1, hints, 0, hints.length - 1);
                            hints[hints.length - 1] = SystemClock.uptimeMillis();
                            prevX = (int) event.getRawX();
                            prevY = (int) event.getRawY();
                            iv_btn_setting_kb_ring.setVisibility(View.GONE);
                            ViewGroup.LayoutParams ring_lp = iv_btn_setting_kb_ring.getLayoutParams();
                            ring_lp.width = g_ringSizeRocker * 2;
                            ring_lp.height = g_ringSizeRocker * 2;
                            iv_btn_setting_kb_ring.setX(v.getX() - (mImgRingSize + mImgRingSize / 4 - mImageHalfSizeEdit));
                            iv_btn_setting_kb_ring.setY(v.getY() - (mImgRingSize + mImgRingSize / 4 - mImageHalfSizeEdit));
                            iv_btn_setting_kb_ring.setVisibility(View.VISIBLE);
                            break;
                        case MotionEvent.ACTION_MOVE:
                            if ((Math.abs(prevX - (int) event.getRawX()) > 20) || (Math.abs(prevY - (int) event.getRawY()) > 20)) {
                                pos_x = (int) event.getRawX() - mImageHalfSizeEdit * 3;
                                pos_y = (int) event.getRawY() - mImageHalfSizeEdit * 3;
                                v.setX(pos_x);
                                v.setY(pos_y);
                                tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()] = (pos_y + mImageHalfSizeEdit * 3) * 0x7FFF / panelHeight;
                                tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1] = (pos_x + mImageHalfSizeEdit * 3) * 0x7FFF / panelWidth;
                                iv_btn_setting_kb_ring.setX(v.getX() - (mImgRingSize + mImgRingSize / 4 - mImageHalfSizeEdit));
                                iv_btn_setting_kb_ring.setY(v.getY() - (mImgRingSize + mImgRingSize / 4 - mImageHalfSizeEdit));
                                iv_kb_button_setting_add.setVisibility(View.GONE);
                                iv_kb_button_setting_remove.setVisibility(View.VISIBLE);
                                showNormalEmptyBtn(false);
                                bIsChanged = true;
                                if ((tempKbTbl[0] & 0xff) != 0xff) {
                                    img_button_edit[tempKbTbl[0]].setX(event.getRawX() - mImageHalfSizeEdit);
                                    img_button_edit[tempKbTbl[0]].setY(event.getRawY() - mImageHalfSizeEdit - mImageHalfSizeEdit * 2 + (float) mImageHalfSizeEdit / 10);
                                    tempCoordinateTbl[2 * tempKbTbl[0]] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()];
                                    tempCoordinateTbl[2 * tempKbTbl[0] + 1] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1];
                                }
                                if ((tempKbTbl[1] & 0xff) != 0xff) {
                                    img_button_edit[tempKbTbl[1]].setX(event.getRawX() - mImageHalfSizeEdit);
                                    img_button_edit[tempKbTbl[1]].setY(event.getRawY() - mImageHalfSizeEdit + mImageHalfSizeEdit * 2 - (float) mImageHalfSizeEdit / 10);
                                    tempCoordinateTbl[2 * tempKbTbl[1]] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()];
                                    tempCoordinateTbl[2 * tempKbTbl[1] + 1] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1];
                                }
                                if ((tempKbTbl[2] & 0xff) != 0xff) {
                                    img_button_edit[tempKbTbl[2]].setX(event.getRawX() - mImageHalfSizeEdit - mImageHalfSizeEdit * 2 + (float) mImageHalfSizeEdit / 10);
                                    img_button_edit[tempKbTbl[2]].setY(event.getRawY() - mImageHalfSizeEdit);
                                    tempCoordinateTbl[2 * tempKbTbl[2]] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()];
                                    tempCoordinateTbl[2 * tempKbTbl[2] + 1] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1];
                                }
                                if ((tempKbTbl[3] & 0xff) != 0xff) {
                                    img_button_edit[tempKbTbl[3]].setX(event.getRawX() - mImageHalfSizeEdit + mImageHalfSizeEdit * 2 - (float) mImageHalfSizeEdit / 10);
                                    img_button_edit[tempKbTbl[3]].setY(event.getRawY() - mImageHalfSizeEdit);
                                    tempCoordinateTbl[2 * tempKbTbl[3]] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()];
                                    tempCoordinateTbl[2 * tempKbTbl[3] + 1] = tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1];
                                }
                            }
                            break;
                        case MotionEvent.ACTION_UP:
                            System.arraycopy(hints, 1, hints, 0, hints.length - 1);
                            hints[hints.length - 1] = SystemClock.uptimeMillis();
                            iv_kb_button_setting_remove.setVisibility(View.GONE);
                            iv_kb_button_setting_add.setVisibility(View.VISIBLE);
                            if ((SystemClock.uptimeMillis() - hints[0] >= 250) || ((Math.abs(prevX - (int) event.getRawX()) > 20) || (Math.abs(prevY - (int) event.getRawY()) > 20))) {
                                bIsLongPress = true;
                            }
                            if ((tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()] != mGlobalVar.coorTbl[2 * mGlobalVar.getDirectCenterIndex()]) || (tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1] != mGlobalVar.coorTbl[2 * mGlobalVar.getDirectCenterIndex() + 1])) {
                                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_COORDINATE, mGlobalVar.getDirectCenterIndex(), (tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()] << 16) + tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1], 3);
                                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_COORDINATE, tempKbTbl[0], (tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()] << 16) + tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1], 3);
                                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_COORDINATE, tempKbTbl[1], (tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()] << 16) + tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1], 3);
                                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_COORDINATE, tempKbTbl[2], (tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()] << 16) + tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1], 3);
                                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_COORDINATE, tempKbTbl[3], (tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex()] << 16) + tempCoordinateTbl[2 * mGlobalVar.getDirectCenterIndex() + 1], 3);
                            }

                            break;
                    }
                    return bIsLongPress;
                }
            });
            iv_kb_setting_direct_edit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (g_preButtonIndex != mGlobalVar.getDirectCenterIndex()) {
                        g_preButtonIndex = mGlobalVar.getDirectCenterIndex();
                        return;
                    }
                    showKBAdvanceSetting();
                }
            });
            bIsImageAlreadyCreate1 = true;
            ar.recycle();
        }
        if (mGlobalVar.getbIsUsbConnect())
            showSplitButton();
    }

    void showNormalEmptyBtn(boolean show) {
        byte u8counter = 0;
        bIsEmptyIconShow = show;
        //showNormalEmptyButton(show);
        if (show)
            iv_kb_button_setting_reserve.setVisibility(View.VISIBLE);
        else
            iv_kb_button_setting_reserve.setVisibility(View.GONE);

        start_x = (int) iv_kb_button_setting_reserve.getX();
        start_y = (int) iv_kb_button_setting_reserve.getY();
        TypedArray ar;
        ar = getResources().obtainTypedArray(R.array.mp1_button_images);

        for (int a = 4; a < 0x64; a++) {
            if(mGlobalVar.switchMouseToKeyEvent((mGlobalVar.getSwitchToMouseKey_KB()&0xff00)>>8,mGlobalVar.getSwitchToMouseKey_KB()&0xff)==a)
                continue;
            if ((tempAttrTbl[a][0] & 0xff) == 0xff) {
                if (show) {
                    img_button_edit[a].setX(start_x + (u8counter % 8) * mImageHalfSizeEdit * 2);
                    img_button_edit[a].setY(start_y + (u8counter >> 3) * mImageHalfSizeEdit * 2);
                    img_button_edit[a].setVisibility(View.VISIBLE);
                    u8counter++;
                } else {
                    img_button_edit[a].setVisibility(View.GONE);
                }
            }
        }
        if (mGlobalVar.getIsSupportMouseSideKeyAndHorSense()) {
            for (int a = 0x80; a < 0x90; a++) {
                if(mGlobalVar.switchMouseToKeyEvent((mGlobalVar.getSwitchToMouseKey_KB()&0xff00)>>8,mGlobalVar.getSwitchToMouseKey_KB()&0xff)==a)
                    continue;

                if ((tempAttrTbl[a][0] & 0xff) == 0xff) {
                    if (show) {
                        img_button_edit[a].setX(start_x + (u8counter % 8) * mImageHalfSizeEdit * 2);
                        img_button_edit[a].setY(start_y + (u8counter >> 3) * mImageHalfSizeEdit * 2);
                        img_button_edit[a].setVisibility(View.VISIBLE);
                        u8counter++;
                    } else {
                        img_button_edit[a].setVisibility(View.GONE);
                    }
                }
            }
        } else {
            for (int a = 0x80; a < 0x8C; a++) {
                if ((tempAttrTbl[a][0] & 0xff) == 0xff) {
                    if (show) {
                        img_button_edit[a].setX(start_x + (u8counter % 8) * mImageHalfSizeEdit * 2);
                        img_button_edit[a].setY(start_y + (u8counter >> 3) * mImageHalfSizeEdit * 2);
                        img_button_edit[a].setVisibility(View.VISIBLE);
                        u8counter++;
                    } else {
                        img_button_edit[a].setVisibility(View.GONE);
                    }
                }
            }
        }
        ar.recycle();

        //int height = dip2px(this, 130);
        ViewGroup.LayoutParams lp = iv_kb_button_setting_reserve.getLayoutParams();
        //Log.d(TAG, "height1:" + String.valueOf(height)+"   "+String.valueOf(((u8counter / 8 + 1) * mImageHalfSizeEdit * 2))+"  "+String.valueOf(mImageHalfSizeEdit));
        if (lp.height < ((u8counter / 8 + 1) * mImageHalfSizeEdit * 2)) {

            lp.height = ((u8counter / 8 + 1) * mImageHalfSizeEdit * 2);
            //Log.d(TAG, "height1:" + String.valueOf(lp.height));
        }
    }

    void showNormalEmptyButton(boolean show) {
        byte u8counter = 0, gap = 10;
        byte u8NumPerLine = (byte) (paramsBtnNoUse.width / (gap + mImageHalfSize * 2));
        if (!bIsImageInitial) {
            TypedArray ar;
            ar = getResources().obtainTypedArray(R.array.mp1_button_images);
            int len = ar.length();
            int[] resIds = new int[len];
            for (int a = 0; a < mGlobalVar.getDirectCenterIndex(); a++) {
                resIds[a] = ar.getResourceId(a, 0);
                img_button_no_use[a] = new ImageView(FloatMenuService_New.this);
                img_button_no_use[a].setImageResource(resIds[a]);
                ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(mImageHalfSize * 2, mImageHalfSize * 2);
                img_button_no_use[a].setAlpha(((float) mGlobalVar.getNormal_Icon_Alpha()) / 10);
                img_button_no_use[a].setVisibility(View.GONE);
                button_no_use_list_layout.addView(img_button_no_use[a], lp);
            }
            bIsImageInitial = true;
            ar.recycle();
        }

        if (show) {
            for (int a = 4; a < 0x53; a++) {
                if ((tempAttrTbl[a][0] & 0xff) == 0xff) {
                    img_button_no_use[a].setX(gap + (u8counter % u8NumPerLine) * (mImageHalfSizeEdit * 2 + gap));
                    img_button_no_use[a].setY(gap + (u8counter / u8NumPerLine) * (mImageHalfSizeEdit * 2 + gap));
                    img_button_no_use[a].setVisibility(View.VISIBLE);
                    u8counter++;
                } else {
                    img_button_no_use[a].setVisibility(View.GONE);
                }
            }
            for (int a = 0x80; a < 0x8C; a++) {
                if ((tempAttrTbl[a][0] & 0xff) == 0xff) {
                    img_button_no_use[a].setX(gap + (u8counter % u8NumPerLine) * (mImageHalfSizeEdit * 2 + gap));
                    img_button_no_use[a].setY(gap + (u8counter / u8NumPerLine) * (mImageHalfSizeEdit * 2 + gap));
                    img_button_no_use[a].setVisibility(View.VISIBLE);
                    u8counter++;
                } else {
                    img_button_no_use[a].setVisibility(View.GONE);
                }
            }
            paramsBtnNoUse.height = ((u8counter / u8NumPerLine + 1) * (mImageHalfSizeEdit * 2 + gap));
            if (!bIsBtnNoUseShow) {
                windowManager.addView(button_no_use_list_layout, paramsBtnNoUse);
                bIsBtnNoUseShow = true;
            }
        } else {
            if (bIsBtnNoUseShow) {
                windowManager.removeView(button_no_use_list_layout);
                bIsBtnNoUseShow = false;
            }
        }
    }


    String parseAutoEvent(int index)   //连招
    {
        String str = "";
        int start = tempAttrTbl[index][1];
        int length = tempAttrTbl[index][2];

        if (tempAttrTbl[index][0] == Transfer_Con.ATTR_MACRO) {
            if (start == 0xffff)
                return str;
            str = getResources().getString(R.string.string_pop_button_setting_advance_macro);
            for (int a = 2; a < (length); a += 4) {
                if ((tempAttrEvTbl[start + a] & 0x80) == 0x80) {
                    str += Transfer_Con.tKeyName[tempAttrEvTbl[start + a + 1]] + getResources().getString(R.string.string_pop_button_setting_advance_event_down_1);
                } else if ((tempAttrEvTbl[start + a] & 0x40) == 0x40) {
                    str += getResources().getString(R.string.string_pop_button_setting_advance_event_swipe) + Transfer_Con.tKeyName[tempAttrEvTbl[start + a + 1]];
                } else {
                    str += Transfer_Con.tKeyName[tempAttrEvTbl[start + a + 1]] + getResources().getString(R.string.string_pop_button_setting_advance_event_up_1);
                }

                if ((a + 4) < length) {
                    if ((tempAttrEvTbl[start + a + 2] == 0) && (tempAttrEvTbl[start + a + 3] == 0)) {
                        str += getResources().getString(R.string.string_pop_button_setting_advance_event_same_time);
                    } else {
                        str += getResources().getString(R.string.string_pop_button_setting_advance_event_wait) + String.valueOf((tempAttrEvTbl[start + a + 2] << 8) | tempAttrEvTbl[start + a + 3]) + "ms, ";
                    }
                }
            }
            str += "。";
        }

        return str;
    }

    String parseTempAutoEvent()   //连招
    {
        String str = "";
        str = getResources().getString(R.string.string_pop_button_setting_advance_macro);
        for (int a = 2; a < (g_mAutoEventTblLen); a += 4) {
            if ((tempAttrEvTblEdit[a] & 0x80) == 0x80) {
                str += Transfer_Con.tKeyName[tempAttrEvTblEdit[a + 1]] + getResources().getString(R.string.string_pop_button_setting_advance_event_down_1);
            } else if ((tempAttrEvTblEdit[a] & 0x40) == 0x40) {
                str += getResources().getString(R.string.string_pop_button_setting_advance_event_swipe) + Transfer_Con.tKeyName[tempAttrEvTblEdit[a + 1]];
            } else {
                str += Transfer_Con.tKeyName[tempAttrEvTblEdit[a + 1]] + getResources().getString(R.string.string_pop_button_setting_advance_event_up_1);
            }
            if ((a + 4) < g_mAutoEventTblLen) {
                if ((tempAttrEvTblEdit[a + 2] == 0) && (tempAttrEvTblEdit[a + 3] == 0)) {
                    str += getResources().getString(R.string.string_pop_button_setting_advance_event_same_time);
                } else {
                    str += getResources().getString(R.string.string_pop_button_setting_advance_event_wait) + String.valueOf((tempAttrEvTblEdit[a + 2] << 8) | (tempAttrEvTblEdit[a + 3])) + "ms, ";
                }
            }
        }
        return str;
    }


    ImageView iv_macro_edit_button_1;
    int button_sub = 0xff;

    public void showMacroEditSetting(int pos) {
        int x = 0, y = 0;
        if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
            if (bIsVirtualMouseShow) {
                windowManager.removeView(virtual_mouse_layout);
                bIsVirtualMouseShowBackup = true;
                bIsVirtualMouseShow = false;
            } else {
                bIsVirtualMouseShowBackup = false;
            }
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(FloatMenuService_New.this);
        //EditText input = new EditText(FloatMenuService_New.this);
        View view = LayoutInflater.from(FloatMenuService_New.this).inflate(R.layout.button_setting_macro_edit_pop_layout, null, false);
        GridView gv_kb_function_select = view.findViewById(R.id.gv_button_setting_macro_edit_pop);
        ImageView iv_macro_edit_button = view.findViewById(R.id.iv_macro_edit_button);
        iv_macro_edit_button_1 = view.findViewById(R.id.iv_macro_edit_button_1);
        TextView tv_macro_edit_pop_coordinate_x = view.findViewById(R.id.tv_macro_edit_pop_coordinate_x);
        final EditText input_macro_edit_pop_coordinate_x = view.findViewById(R.id.input_macro_edit_pop_coordinate_x);
        TextView tv_macro_edit_pop_coordinate_y = view.findViewById(R.id.tv_macro_edit_pop_coordinate_y);
        final EditText input_macro_edit_pop_coordinate_y = view.findViewById(R.id.input_macro_edit_pop_coordinate_y);
        TextView tv_macro_edit_pop_time = view.findViewById(R.id.tv_macro_edit_pop_time);
        final EditText input_macro_edit_pop_time = view.findViewById(R.id.input_macro_edit_pop_time);
        LinearLayout ll_pop_macro_edit_virtual_x = view.findViewById(R.id.ll_pop_macro_edit_virtual_x);
        LinearLayout ll_pop_macro_edit_virtual_y = view.findViewById(R.id.ll_pop_macro_edit_virtual_y);
        LinearLayout ll_macro_edit_button = view.findViewById(R.id.ll_macro_edit_button);

        final LinearLayout gv_button_setting_macro_edit_pop_layout = view.findViewById(R.id.gv_button_setting_macro_edit_pop_layout);
        final List<Map<String, Object>> data_list;
        SimpleAdapter sim_adapter;
        data_list = new ArrayList<Map<String, Object>>();
        TypedArray ar = getResources().obtainTypedArray(R.array.mp1_button_images);
        int len = ar.length();
        int[] resIds = new int[len];
        //Toast.makeText(FloatMenuService_New.this,String.format("time=%x,but=%d,t=%d,%d",tempAttrEvTblEdit[pos*4],tempAttrEvTblEdit[pos*4+1],tempAttrEvTblEdit[pos*4+2],tempAttrEvTblEdit[pos*4+3]),Toast.LENGTH_SHORT).show();
        for (int a = 0; a < len; a++) {
            Map<String, Object> map = new HashMap<String, Object>();
            resIds[a] = ar.getResourceId(a, 0);
            map.put("image", resIds[a]);
            map.put("id", a);
            data_list.add(map);
        }
        if (g_bIsVirtualEdit) {
            x = (int) listData.get(pos).get("cr");
            y = x >> 16;
            x = x & 0xffff;
            ll_macro_edit_button.setVisibility(View.GONE);
            tv_macro_edit_pop_coordinate_x.setText("X位置从" + String.valueOf(x));
            tv_macro_edit_pop_coordinate_y.setText("Y位置从" + String.valueOf(y));
            input_macro_edit_pop_coordinate_x.setText(String.valueOf(x));
            input_macro_edit_pop_coordinate_y.setText(String.valueOf(y));
        } else {
            iv_macro_edit_button.setImageResource(resIds[(int) listData.get(pos).get("btn")]);
            iv_macro_edit_button_1.setImageResource(resIds[(int) listData.get(pos).get("btn")]);
            ll_pop_macro_edit_virtual_x.setVisibility(View.GONE);
            ll_pop_macro_edit_virtual_y.setVisibility(View.GONE);

        }
        tv_macro_edit_pop_time.setText("时间从" + String.valueOf((int) listData.get(pos).get("time")) + "毫秒");
        input_macro_edit_pop_time.setText(String.valueOf((int) listData.get(pos).get("time")));
        String[] from = {"image"};
        int[] to = {R.id.iv_kb_gv};
        button_sub = pos;
        sim_adapter = new SimpleAdapter(FloatMenuService_New.this, data_list, R.layout.kb_function_select_gv_content, from, to);
        gv_kb_function_select.setAdapter(sim_adapter);
        gv_kb_function_select.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                gv_button_setting_macro_edit_pop_layout.setVisibility(View.GONE);
                TypedArray ar = getResources().obtainTypedArray(R.array.mp1_button_images);
                int resIds = ar.getResourceId(position, 0);
                iv_macro_edit_button_1.setImageResource(resIds);
                button_sub = position;
                ar.recycle();
            }
        });


        ar.recycle();
        final int sub_x = x, sub_y = y, sub_pos = pos;
        builder.setView(view);
        builder.setTitle(getResources().getString(R.string.str_global_more_function_setting))
                .setPositiveButton(getResources().getString(R.string.string_pop_confirm), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        int x = sub_x, y = sub_y;
                        int delay = 200;
                        if (!android.text.TextUtils.isEmpty(input_macro_edit_pop_time.getText())) {
                            delay = Integer.parseInt(input_macro_edit_pop_time.getText().toString());
                        }
                        if (g_bIsVirtualEdit) {
                            if (!android.text.TextUtils.isEmpty(input_macro_edit_pop_coordinate_x.getText())) {
                                x = Integer.parseInt(input_macro_edit_pop_coordinate_x.getText().toString());
                            }
                            if (!android.text.TextUtils.isEmpty(input_macro_edit_pop_coordinate_y.getText())) {
                                y = Integer.parseInt(input_macro_edit_pop_coordinate_y.getText().toString());
                            }
                            x = (x * 0x7FFF + panelWidth / 2) / panelWidth;
                            ;
                            y = (y * 0x7FFF + panelHeight / 2) / panelHeight;

                            tempAttrEvTblEdit[2 + sub_pos * 6] = (byte) (tempAttrEvTblEdit[2 + sub_pos * 6] & 0x80 | ((y & 0x0000FF00) >> 8));
                            tempAttrEvTblEdit[2 + sub_pos * 6 + 1] = (byte) ((y & 0x000000FF));
                            tempAttrEvTblEdit[2 + sub_pos * 6 + 2] = (byte) (((x & 0x0000FF00) >> 8));
                            tempAttrEvTblEdit[2 + sub_pos * 6 + 3] = (byte) ((x & 0x000000FF));
                            tempAttrEvTblEdit[2 + sub_pos * 6 + 4] = (delay & 0xff00) << 8;
                            tempAttrEvTblEdit[2 + sub_pos * 6 + 5] = (delay & 0x00ff);
                        } else {
                            //Toast.makeText(FloatMenuService_New.this,String.format("time=%x,but=%d,t=%d,%d",tempAttrEvTblEdit[2+sub_pos*4],tempAttrEvTblEdit[2+sub_pos*4+1],tempAttrEvTblEdit[2+sub_pos*4+2],tempAttrEvTblEdit[2+sub_pos*4+3]),Toast.LENGTH_SHORT).show();
                            if (button_sub != sub_pos) {
                                tempAttrEvTblEdit[2 + sub_pos * 4 + 1] = button_sub;
                                tempAttrEvTblEdit[2 + sub_pos * 4 + 2] = (delay & 0xff00) << 8;
                                tempAttrEvTblEdit[2 + sub_pos * 4 + 3] = (delay & 0x00ff);
                            } else {
                                tempAttrEvTblEdit[2 + sub_pos * 4 + 2] = (delay & 0xff00) << 8;
                                tempAttrEvTblEdit[2 + sub_pos * 4 + 3] = (delay & 0x00ff);
                            }

                        }
                        parseEvToList();
                        myEditAdapter.notifyDataSetChanged();
                    }
                })
                .setNegativeButton(getResources().getString(R.string.string_pop_cancel), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
        final AlertDialog dialog = builder.create();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (Settings.canDrawOverlays(FloatMenuService_New.this))
                dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
        } else {
            dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        }
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
        if (mGlobalVar.getIsSupportVirtualMouse_KB()) {
            if (bIsVirtualMouseShowBackup) {
                windowManager.addView(virtual_mouse_layout, paramsVirtualMouse);
                bIsVirtualMouseShow = true;
            }
        }
        iv_macro_edit_button_1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gv_button_setting_macro_edit_pop_layout.setVisibility(View.VISIBLE);
            }
        });
    }


    class MyEditAdapter extends BaseAdapter {
        @Override
        public int getCount() {
            return listData.size();
        }

        @Override
        public Object getItem(int position) {
            return listData.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder mHolder;
            final int pos = position;
            TypedArray ar = getResources().obtainTypedArray(R.array.mp1_button_images);


            if (convertView == null) {
                mHolder = new ViewHolder();
                LayoutInflater inflater = LayoutInflater.from(FloatMenuService_New.this);
                convertView = inflater.inflate(R.layout.listview_macro_edit_layout, null, true);
                mHolder.tv_step = convertView.findViewById(R.id.tv_macro_edit_step);
                mHolder.tv_coordinate = convertView.findViewById(R.id.tv_macro_edit_coordinate);
                mHolder.iv_button = convertView.findViewById(R.id.iv_macro_edit_button);
                mHolder.tv_action = convertView.findViewById(R.id.tv_macro_edit_action);
                mHolder.tv_time = convertView.findViewById(R.id.tv_macro_edit_time);
                mHolder.btn_edit = convertView.findViewById(R.id.btn_macro_edit_modify);
                convertView.setTag(mHolder);
            } else {
                mHolder = (ViewHolder) convertView.getTag();
            }
            mHolder.tv_step.setText(String.valueOf(pos + 1));
            if ((int) listData.get(pos).get("btn") == 0xff) {
                int x = (int) listData.get(pos).get("cr");
                int y = x >> 16;
                x = x & 0xffff;
                mHolder.tv_coordinate.setText(String.format("坐标(%d,%d)", x, y));
            } else //if((int)listData.get(pos).get("btn")!=0xff)
            {
                int resIds = ar.getResourceId((int) listData.get(pos).get("btn"), 0);
                mHolder.iv_button.setImageResource(resIds);
            }
            if ((int) listData.get(pos).get("act") == 1) {
                mHolder.tv_action.setText("松开");
            } else if ((int) listData.get(pos).get("act") == 2) {
                mHolder.tv_action.setText("滑至");
            } else {
                mHolder.tv_action.setText("按下");
            }
            if ((int) listData.get(pos).get("time") == 0xff)
                mHolder.tv_time.setText("结束");
            else
                mHolder.tv_time.setText(String.valueOf((int) listData.get(pos).get("time")) + "毫秒");
            ar.recycle();

            mHolder.btn_edit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    showMacroEditSetting(pos);
                }
            });
            return convertView;
        }

        class ViewHolder {
            TextView tv_step;
            TextView tv_coordinate;
            ImageView iv_button;
            TextView tv_action;
            TextView tv_time;
            Button btn_edit;
        }
    }

    ;

    void parseEvToList() {
        listData = new ArrayList<Map<String, Object>>();
        if (((tempAttrTblEdit[0] & Transfer_Con.ATTR_MASK) == Transfer_Con.ATTR_MACRO_ADV)) {
            for (int a = 2; a < (g_mAutoEventTblLen); a += 6) {
                Map<String, Object> map = new HashMap<String, Object>();
                // Log.d(TAG,String.format("--------------->www 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, ",tempAttrEvTblEdit[a],tempAttrEvTblEdit[a+1],tempAttrEvTblEdit[a+2],tempAttrEvTblEdit[a+3],tempAttrEvTblEdit[a+4]));
                if ((tempAttrEvTblEdit[a] & 0x80) == 0x80) {
                    int x = ((tempAttrEvTblEdit[a] & 0xff) & 0x7f) * 256 + (tempAttrEvTblEdit[a + 1] & 0xff);
                    int y = ((tempAttrEvTblEdit[a + 2] & 0xff) & 0x7f) * 256 + (tempAttrEvTblEdit[a + 3] & 0xff);

                    x = (x * panelHeight + 0x3FFF) / 0x7FFF;
                    y = (y * panelWidth + 0x3FFF) / 0x7FFF;
                    map.put("id", 0);
                    map.put("cr", (x << 16) + y);
                    map.put("btn", 0xff);
                    map.put("act", 0);
                } else if ((tempAttrEvTblEdit[a + 2] & 0x80) == 0x80) {
                    int x = ((tempAttrEvTblEdit[a] & 0xff) & 0x7f) * 256 + (tempAttrEvTblEdit[a + 1] & 0xff);
                    int y = ((tempAttrEvTblEdit[a + 2] & 0xff) & 0x7f) * 256 + (tempAttrEvTblEdit[a + 3] & 0xff);

                    x = (x * panelHeight + 0x3FFF) / 0x7FFF;
                    y = (y * panelWidth + 0x3FFF) / 0x7FFF;
                    map.put("id", 0);
                    map.put("cr", (x << 16) + y);
                    map.put("btn", 0xff);
                    map.put("act", 2);

                } else {
                    int x = ((tempAttrEvTblEdit[a] & 0xff) & 0x7f) * 256 + (tempAttrEvTblEdit[a + 1] & 0xff);
                    int y = ((tempAttrEvTblEdit[a + 2] & 0xff) & 0x7f) * 256 + (tempAttrEvTblEdit[a + 3] & 0xff);

                    x = (x * panelHeight + 0x3FFF) / 0x7FFF;
                    y = (y * panelWidth + 0x3FFF) / 0x7FFF;
                    map.put("id", 0);
                    map.put("cr", (x << 16) + y);
                    map.put("btn", 0xff);
                    map.put("act", 1);
                }
                if (tempAttrEvTblEdit[a + 4] == (byte) 0xFF) {
                    map.put("time", 0xff);
                    listData.add(map);
                    break;
                }
                if (tempAttrEvTblEdit[a + 4] == 0) {
                    //str += getResources().getString(R.string.string_pop_button_setting_advance_event_same_time);
                    map.put("time", 0);
                } else {
                    //str += getResources().getString(R.string.string_pop_button_setting_advance_event_wait) + String.valueOf((tempAttrEvTblEdit[a + 4] & 0xFF) * 10) + "ms, ";
                    map.put("time", (tempAttrEvTblEdit[a + 4] & 0xFF) * 10);
                }
                listData.add(map);
            }
        } else if ((tempAttrTblEdit[0] & Transfer_Con.ATTR_MASK) == Transfer_Con.ATTR_MACRO) {
            for (int a = 2; a < (g_mAutoEventTblLen); a += 4) {
                Map<String, Object> map = new HashMap<String, Object>();
                if ((tempAttrEvTblEdit[a] & 0x80) == 0x80) {
                    // str += Transfer_Con.tButtonName[tempAttrEvTblEdit[a] & 0x3F] + getResources().getString(R.string.string_pop_button_setting_advance_event_down_1);
                    map.put("id", 0);
                    map.put("cr", 0xffffffff);
                    map.put("btn", tempAttrEvTblEdit[a + 1] & 0xff);
                    map.put("act", 0);
                } else if ((tempAttrEvTblEdit[a] & 0x40) == 0x40) {
                    //str += getResources().getString(R.string.string_pop_button_setting_advance_event_swipe) + Transfer_Con.tButtonName[tempAttrEvTblEdit[a] & 0x3F];
                    map.put("id", 0);
                    map.put("cr", 0xffffffff);
                    map.put("btn", tempAttrEvTblEdit[a + 1] & 0xff);
                    map.put("act", 2);
                } else {
                    //str += Transfer_Con.tButtonName[tempAttrEvTblEdit[a] & 0x3F] + getResources().getString(R.string.string_pop_button_setting_advance_event_up_1);
                    map.put("id", 0);
                    map.put("cr", 0xffffffff);
                    map.put("btn", tempAttrEvTblEdit[a + 1] & 0xff);
                    map.put("act", 1);
                }
                if (tempAttrEvTblEdit[a + 4] == (byte) 0xFF) {
                    map.put("time", 0xff);
                    listData.add(map);
                    break;
                }
                if ((tempAttrEvTblEdit[a + 2] == 0) && (tempAttrEvTblEdit[a + 3] == 0)) {
                    //str += getResources().getString(R.string.string_pop_button_setting_advance_event_same_time);
                    map.put("time", 0);
                } else {
                    //str += getResources().getString(R.string.string_pop_button_setting_advance_event_wait) + String.valueOf((tempAttrEvTblEdit[a + 1] & 0xff) * 10) + "ms, ";
                    map.put("time", ((tempAttrEvTblEdit[a + 2] << 8) | tempAttrEvTblEdit[a + 3]));
                }
                listData.add(map);
            }
        }
    }


    /*
    public void sendCoordinateToDevice_KB()
    {
        byte length = 20;
        if(mGlobalVar.getbIsUsbConnect())
        {
            for(int a=0;a<Transfer_Con.MAX_COORDINATE*2;)
            {
                //String str="";
                for(int k=0;k<length;k++)
                {
                    u8DataBuffer[k * 2] = (byte) (mGlobalVar.coorTbl[a+k] & 0xff);
                    u8DataBuffer[k * 2 + 1] = (byte) (mGlobalVar.coorTbl[a+k] >> 8);
                  //  str += String.format("%d,%d,",u8DataBuffer[k * 2],u8DataBuffer[k * 2+1]);
                }
                //Log.d(TAG,str);
                if (mGlobalVar.tranSet_MultiValue(Transfer_Con.HID_CMD_SET_POINT_TBL, a, length*2,u8DataBuffer))
                {
                    a+=length;
                    if((a+length)>Transfer_Con.MAX_COORDINATE*2)
                        length = (byte)(Transfer_Con.MAX_COORDINATE*2 - a);
                }
            }
            Toast.makeText(FloatMenuService_New.this,getResources().getString(R.string.string_pop_file_save_success),Toast.LENGTH_SHORT).show();
        }

    }

    public void getCoordinateFromDevice_KB()
    {
        byte length = 20;
        //String str="";
        if(mGlobalVar.getbIsUsbConnect())
        {
            for(int a=0;a<Transfer_Con.MAX_COORDINATE*2;)
            {
                if (mGlobalVar.tranGet_Value(Transfer_Con.HID_CMD_GET_POINT_TBL, a, length*2,u8DataBuffer))
                {
                    for(int k=0;k<length;k++)
                    {
                        mGlobalVar.coorTbl[a+k] = (u8DataBuffer[16+k * 2]&0xff)+ ((u8DataBuffer[16+k * 2 + 1]&0xff)<<8);
                        //str= str + String.valueOf(u8DataBuffer[16+k * 2])+", "+ String.valueOf(u8DataBuffer[16+k * 2+1])+", ";
                        //str= str + String.valueOf(mGlobalVar.coorTbl[a+k])+", ";
                    }
                    a+=length;
                    if((a+length)>Transfer_Con.MAX_COORDINATE*2)
                        length = (byte)(Transfer_Con.MAX_COORDINATE*2 - a);
                }
            }
            //Log.d(TAG,str);
        }
    }

    public void sendAttributeToDevice_KB()
    {
        byte length = 40;
        if(mGlobalVar.getbIsUsbConnect())
        {
            for(int i=0;i<5;i++)
            {
                for(int a=0;a<Transfer_Con.MAX_COORDINATE;)
                {
                    if(i==0)
                    {
                        for (int k = 0; k < length; k++) {
                            u8DataBuffer[k] = (byte) (mGlobalVar.attrTbl[a + k][i] & 0xff);
                        }
                    }
                    else if(i==1)
                    {
                        for (int k = 0; k < length; k++) {
                            u8DataBuffer[k] = (byte) ((mGlobalVar.attrTbl[a + k][1] & 0xff));
                        }
                    }
                    else if(i==2)
                    {
                        for (int k = 0; k < length; k++) {
                            u8DataBuffer[k] = (byte) ((mGlobalVar.attrTbl[a + k][1] & 0xff00)>>8);
                        }
                    }
                    else if(i==3)
                    {
                        for (int k = 0; k < length; k++) {
                            u8DataBuffer[k] = (byte) ((mGlobalVar.attrTbl[a + k][2] & 0xff));
                        }
                    }
                    else //if(i==4)
                    {
                        for (int k = 0; k < length; k++) {
                            u8DataBuffer[k] = (byte) ((mGlobalVar.attrTbl[a + k][2] & 0xff00)>>8);
                        }
                    }
                    if (mGlobalVar.tranSet_MultiValue(Transfer_Con.HID_CMD_SET_AEV_TBL, (i<<16)|a, length, u8DataBuffer))
                    {
                        a+=length;
                        if((a+length)>Transfer_Con.MAX_COORDINATE*2)
                            length = (byte)(Transfer_Con.MAX_COORDINATE*2 - a);
                    }
                }
            }
        }
    }
    public void getAttributeFromDevice_KB()
    {
        byte length = 40;
        if(mGlobalVar.getbIsUsbConnect())
        {
            for(int i=0;i<5;i++)
            {
                for(int a=0;a<Transfer_Con.MAX_COORDINATE;)
                {

                    if (mGlobalVar.tranGet_Value(Transfer_Con.HID_CMD_GET_AEV_TBL, (i<<16)|a, length, u8DataBuffer))
                    {
                        if(i==0)
                        {
                            for (int k = 0; k < length; k++) {
                                mGlobalVar.attrTbl[a + k][i] = u8DataBuffer[16+k]&0x00ff;
                            }
                        }
                        else if(i==1)
                        {
                            for (int k = 0; k < length; k++) {
                                mGlobalVar.attrTbl[a + k][1] = (mGlobalVar.attrTbl[a + k][1]&0xff00) + (u8DataBuffer[16+k] &0xff);
                            }
                        }
                        else if(i==2)
                        {
                            for (int k = 0; k < length; k++) {
                                mGlobalVar.attrTbl[a + k][1] = (mGlobalVar.attrTbl[a + k][1]&0x00ff)+((u8DataBuffer[16+k]&0xff)<<8);
                            }
                        }
                        else if(i==3)
                        {
                            for (int k = 0; k < length; k++) {
                                mGlobalVar.attrTbl[a + k][2] = (mGlobalVar.attrTbl[a + k][2]&0xff00) + (u8DataBuffer[16+k] &0xff);
                            }
                        }
                        else //if(i==4)
                        {
                            for (int k = 0; k < length; k++) {
                                mGlobalVar.attrTbl[a + k][2] = (mGlobalVar.attrTbl[a + k][2]&0x00ff)+((u8DataBuffer[16+k]&0xff)<<8);
                            }
                        }
                        a+=length;
                        if((a+length)>Transfer_Con.MAX_COORDINATE*2)
                            length = (byte)(Transfer_Con.MAX_COORDINATE*2 - a);
                    }
                }
            }
        }
    }
    public void sendAttributeEventTableToDevice_KB()
    {

    }

    public void getAttributeEventTableFromDevice_KB()
    {

    }

    */




    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            switch (v.getId()) {
                case R.id.ll_float_menu_quick:

                    if(bIsPositionDataShow)
                    {
                        bIsPositionDataShow = false;
                        windowManager.removeView(kb_position_data_layout);
                    }
                    if(bIsQuickSettingShow) {
                        windowManager.removeView(kb_Quick_Setting_Layout);
                        bIsQuickSettingShow = false;
                    }
                    else
                    {
                        bIsQuickSettingShow = true;
                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                        {
                            if(bIsVirtualMouseShow)
                            {
                                windowManager.removeView(virtual_mouse_layout);
                                bIsVirtualMouseShowBackup = true;
                                bIsVirtualMouseShow = false;
                            }
                            else
                            {
                                bIsVirtualMouseShowBackup = false;
                            }
                        }
                        //sb_kb_function_mouse_sense.setMin(1);
                        if(mGlobalVar.getIsSupportMouseSideKeyAndHorSense())
                        {
                            layout_kb_float_quick_mouse_sense_ver.setVisibility(View.VISIBLE);
                            if (mGlobalVar.tranGet_Value_retry(Transfer_Con.HID_CMD_GET_R_ROCK_MIN, 0, 0, u8DataBuffer,5)) {
                                sb_kb_float_quick_mouse_sense_val.setProgress(u8DataBuffer[0]&0xff);
                                tv_kb_float_quick_mouse_sense_val.setText(String.valueOf(u8DataBuffer[0]&0xff));
                            }
                            if (mGlobalVar.tranGet_Value_retry(Transfer_Con.HID_CMD_GET_R_ROCK_MAX, 0, 0, u8DataBuffer,5)) {
                                sb_kb_float_quick_mouse_sense_ver_val.setProgress(u8DataBuffer[0]&0xff);
                                tv_kb_float_quick_mouse_sense_ver_val.setText(String.valueOf(u8DataBuffer[0]&0xff));
                            }
                            if(true)
                            {
                                layout_kb_float_quick_mouse_factor_hor.setVisibility(View.VISIBLE);
                                layout_kb_float_quick_mouse_factor_ver.setVisibility(View.VISIBLE);
                                if (mGlobalVar.tranGet_Value_retry(Transfer_Con.HID_CMD_GET_MOUSE_FACTOR, 0, 0, u8DataBuffer,5)) {
                                    sb_kb_float_quick_mouse_factor_val.setProgress(u8DataBuffer[0]&0xff);
                                    tv_kb_float_quick_mouse_factor_val.setText(String.valueOf(sb_kb_float_quick_mouse_factor_val.getProgress())+"%");
                                    sb_kb_float_quick_mouse_factor_ver_val.setProgress(u8DataBuffer[4]&0xff);
                                    tv_kb_float_quick_mouse_factor_ver_val.setText(String.valueOf(sb_kb_float_quick_mouse_factor_ver_val.getProgress())+"%");
                                }
                            }
                        }
                        else {
                            if (mGlobalVar.tranGet_Value_retry(Transfer_Con.HID_CMD_GET_R_ROCK_MIN, 0, 0, u8DataBuffer,5)) {
                                sb_kb_float_quick_mouse_sense_val.setProgress(u8DataBuffer[0]&0xff);
                                tv_kb_float_quick_mouse_sense_val.setText(String.valueOf(u8DataBuffer[0]&0xff));
                            }
                        }

                        if (mGlobalVar.tranGet_Value_retry(Transfer_Con.HID_CMD_GET_HW_SETTING, 0, 1, u8DataBuffer,5))
                        {
                            if((u8DataBuffer[0]&0x01)==0x01)
                                rb_kb_float_quick_setting_office.setChecked(true);
                            else
                                rb_kb_float_quick_setting_game.setChecked(true);
                        }

                        windowManager.addView(kb_Quick_Setting_Layout, paramsQuickSetting);
                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                        {
                            if(bIsVirtualMouseShowBackup)
                            {
                                windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                                bIsVirtualMouseShow = true;
                            }
                        }
                    }
                    break;
                case R.id.ll_float_menu_setting:
                    if(bIsBtnPreShow) {
                        windowManager.removeView(button_preview_notouch_layout);
                        bIsBtnPreShow = false;
                    }
                    if(bIsFloatMenuShow) {
                        windowManager.removeView(float_menu_layout);
                        bIsFloatMenuShow = false;
                    }
                    if(bIsQuickSettingShow) {
                        windowManager.removeView(kb_Quick_Setting_Layout);
                        bIsQuickSettingShow = false;
                    }
                    if(bIsPositionDataShow)
                    {
                        bIsPositionDataShow = false;
                        windowManager.removeView(kb_position_data_layout);
                    }
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShow)
                        {
                            windowManager.removeView(virtual_mouse_layout);
                            bIsVirtualMouseShowBackup = true;
                            bIsVirtualMouseShow = false;
                        }
                        else
                        {
                            bIsVirtualMouseShowBackup = false;
                        }
                    }
                    windowManager.addView(button_pos_edit_layout, paramsBtnPosEdit);

                    iv_btn_setting_kb_ring.setVisibility(View.GONE);
                    windowManager.addView(kb_float_menu_layout, paramsKBFloatMenu);
                    bIsKBFloatMenuShow = true;
                    bIsEmptyIconShow = false;
                    iv_kb_button_setting_reserve.setVisibility(View.GONE);
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShowBackup)
                        {
                            windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                            bIsVirtualMouseShow = true;
                        }
                    }
                    if(mGlobalVar.getIsSupportEditMode_KB()) {
                        mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_EDIT_MODE, 0xA55AB44B, 1,3);
                        bIsBtnPosEdit = true;
                    }
                    break;
                case R.id.ll_float_menu_home:
                    Intent intent = new Intent();
                    intent.setClass(getBaseContext(), MainActivity.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    getApplication().startActivity(intent);
                    hideWin();
                    break;
                case R.id.ll_float_menu_visible:
                    if(bIsQuickSettingShow) {
                        windowManager.removeView(kb_Quick_Setting_Layout);
                        bIsQuickSettingShow = false;
                    }
                    if(bIsPositionDataShow)
                    {
                        bIsPositionDataShow = false;
                        windowManager.removeView(kb_position_data_layout);
                    }
                    if(bIsBtnPreShow) {
                        windowManager.removeView(button_preview_notouch_layout);
                        bIsBtnPreShow = false;
                        bIsBtnPreShowTemp = false;
                        iv_float_menu_visible.setImageResource(R.drawable.visible);
                        tv_float_menu_visible.setText(getResources().getString(R.string.string_float_menu_visible));
                    }
                    else {
                        windowManager.addView(button_preview_notouch_layout, paramsBtnPre);
                        iv_float_menu_visible.setImageResource(R.drawable.invisible);
                        tv_float_menu_visible.setText(getResources().getString(R.string.string_float_menu_hide));
                        bIsBtnPreShow = true;
                        bIsBtnPreShowTemp = true;
                    }
                    break;
                case R.id.ll_float_menu_data:
                    if(bIsQuickSettingShow) {
                        windowManager.removeView(kb_Quick_Setting_Layout);
                        bIsQuickSettingShow = false;
                    }

                    if(bIsPositionDataShow)
                    {
                        bIsPositionDataShow = false;
                        windowManager.removeView(kb_position_data_layout);
                    }
                    else
                    {
                        bIsPositionDataShow = true;
                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                        {
                            if(bIsVirtualMouseShow)
                            {
                                windowManager.removeView(virtual_mouse_layout);
                                bIsVirtualMouseShow = false;
                                bIsVirtualMouseShowBackup = true;
                            }
                            else
                            {
                                bIsVirtualMouseShowBackup = false;
                            }
                        }
                        windowManager.addView(kb_position_data_layout, paramsPositionData);
                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                        {
                            if(bIsVirtualMouseShowBackup)
                            {
                                windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                                bIsVirtualMouseShow = true;
                            }
                        }
                    }

                    break;
                case R.id.kb_float_menu_layout_save:
                    Boolean bIsShotHelp =false;
                    bIsMacroChange = false;
                    mGlobalVar.coorTbl = tempCoordinateTbl.clone();
                    //mGlobalVar.attrTbl = tempAttrTbl.clone();
                    for(int k=0;k<Transfer_Con.MAX_COORDINATE;k++)
                    {
                        mGlobalVar.attrTbl[k][0] = tempAttrTbl[k][0];
                        mGlobalVar.attrTbl[k][1] = tempAttrTbl[k][1];
                        mGlobalVar.attrTbl[k][2] = tempAttrTbl[k][2];

                        if(tempAttrTbl[k][0]==Transfer_Con.bFPSPullGunDown)
                            bIsShotHelp = true;
                    }
                    mGlobalVar.attrEvTbl = tempAttrEvTbl.clone();
                    mGlobalVar.sendCoordinateToDevice_KB();
                    mGlobalVar.sendAttributeToDevice_KB();
                    mGlobalVar.sendAttributeEventTableToDevice_KB();
                    //Log.d(TAG,"------------------------------------------------------------->"+String.valueOf(mShotHelpImageIndex[14])+"  ====  "+String.valueOf(mShotHelpImageIndexBackup[14]));
                    if(bIsShotHelp) {
                        if (mShotHelpImageIndexBackup[14] != mShotHelpImageIndex[14]) {
                            int group, key;
                            if ((mShotHelpImageIndex[14] & 0xFF) >= 0x80) {
                                if ((mShotHelpImageIndex[14] & 0xFF) < 0x88) {
                                    group = 0;
                                    key = 1 << ((mShotHelpImageIndex[14] & 0xFF) - 0x80);
                                } else {
                                    group = 2;
                                    key = 1 << ((mShotHelpImageIndex[14] & 0xFF) - 0x8A);
                                }
                            } else {
                                group = 1;
                                key = (mShotHelpImageIndex[14] & 0xFF);
                            }
                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_SHOT_INDEX, group, key, 3);
                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SAVE_DATA, 0x00, 0x00, 3);
                            mShotHelpImageIndexBackup[14] = mShotHelpImageIndex[14];
                        }
                    }
                    else
                    {
                        mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_SHOT_INDEX, 0, 0, 3);
                        mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SAVE_DATA, 0x00, 0x00, 3);
                    }
                    //mGlobalVar.sendLocalSettingToDevice();
                    mGlobalVar.saveGameData_KB(mGlobalVar.curPkgName,mGlobalVar.curLabelName,mGlobalVar.coorTbl,mGlobalVar.attrTbl,mGlobalVar.attrEvTbl);
                    Toast.makeText(FloatMenuService_New.this,getResources().getString(R.string.string_pop_file_save_success),Toast.LENGTH_SHORT).show();
                    bIsChanged = false;
                    break;
                case R.id.kb_float_menu_layout_cancel:

                    for(int k=0;k<Transfer_Con.MAX_COORDINATE;k++)
                    {
                        if((tempCoordinateTbl[2*k]!=mGlobalVar.coorTbl[2*k])||(tempCoordinateTbl[2*k+1]!=mGlobalVar.coorTbl[2*k+1]))
                        {
                            tempCoordinateTbl[2*k] = mGlobalVar.coorTbl[2*k];
                            tempCoordinateTbl[2*k+1] = mGlobalVar.coorTbl[2*k+1];
                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_COORDINATE,k,(tempCoordinateTbl[2 * k]<<16)+tempCoordinateTbl[2 * k + 1],3);
                        }
                    }
                    //tempCoordinateTbl = mGlobalVar.coorTbl.clone();
                    for(int k=0;k<Transfer_Con.MAX_COORDINATE;k++)
                    {
                        tempAttrTbl[k][0] = mGlobalVar.attrTbl[k][0];
                        tempAttrTbl[k][1] = mGlobalVar.attrTbl[k][1];
                        tempAttrTbl[k][2] = mGlobalVar.attrTbl[k][2];
                    }

                    tempAttrEvTbl = mGlobalVar.attrEvTbl.clone();

                    showFloatImage();
                    iv_btn_setting_kb_ring.setVisibility(View.GONE);
                    bIsChanged = false;
                    message = handler.obtainMessage();
                    message.what = 0;
                    message.arg1 = (int) paramsFloatLogo.x;
                    message.arg2 = (int) paramsFloatLogo.y;
                    handler.sendMessageDelayed(message, MENU_STAY_TIME);
                    break;
                case R.id.kb_float_menu_layout_exit:
                    if (bIsChanged) {
                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                        {
                            if(bIsVirtualMouseShow)
                            {
                                windowManager.removeView(virtual_mouse_layout);
                                bIsVirtualMouseShow = false;
                                bIsVirtualMouseShowBackup = true;
                            }
                            else
                            {
                                bIsVirtualMouseShowBackup = false;
                            }
                        }
                        AlertDialog.Builder builder = new AlertDialog.Builder(getBaseContext());
                        builder.setTitle(getResources().getString(R.string.string_pop_reminder))
                                .setMessage(getResources().getString(R.string.string_pop_button_setting_exit_reminder))
                                .setPositiveButton(getResources().getString(R.string.string_pop_button_setting_exit_save), new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        mGlobalVar.coorTbl = tempCoordinateTbl.clone();
                                        for(int k=0;k<Transfer_Con.MAX_COORDINATE;k++)
                                        {
                                            mGlobalVar.attrTbl[k][0] = tempAttrTbl[k][0];
                                            mGlobalVar.attrTbl[k][1] = tempAttrTbl[k][1];
                                            mGlobalVar.attrTbl[k][2] = tempAttrTbl[k][2];
                                        }
                                        mGlobalVar.attrEvTbl = tempAttrEvTbl.clone();
                                        mGlobalVar.sendCoordinateToDevice_KB();
                                        mGlobalVar.sendAttributeToDevice_KB();
                                        mGlobalVar.sendAttributeEventTableToDevice_KB();
                                        //mGlobalVar.sendLocalSettingToDevice();
                                        mGlobalVar.saveGameData_KB(mGlobalVar.curPkgName,mGlobalVar.curLabelName,mGlobalVar.coorTbl,mGlobalVar.attrTbl,mGlobalVar.attrEvTbl);
                                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                                        {
                                            if(bIsVirtualMouseShow)
                                            {
                                                windowManager.removeView(virtual_mouse_layout);
                                                bIsVirtualMouseShow = false;
                                                bIsVirtualMouseShowBackup = true;
                                            }
                                            else
                                            {
                                                bIsVirtualMouseShowBackup = false;
                                            }
                                        }
                                        if(bIsKBFloatMenuShow)
                                        {
                                            windowManager.removeView(kb_float_menu_layout);
                                            bIsKBFloatMenuShow = false;
                                        }
                                        if(bIsBtnPosEdit)
                                        {
                                            windowManager.removeView(button_pos_edit_layout);
                                            bIsBtnPosEdit = false;
                                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_EDIT_MODE,0,0,3);
                                        }
                                        windowManager.addView(button_preview_notouch_layout, paramsBtnPre);
                                        bIsBtnPreShow = true;
                                        bIsBtnPreShowTemp = true;
                                        windowManager.addView(float_menu_layout, paramsFloatMenu);
                                        bIsFloatMenuShow = true;
                                        showFloatImage();
                                        Toast.makeText(FloatMenuService_New.this,getResources().getString(R.string.string_pop_file_save_success),Toast.LENGTH_SHORT).show();
                                        iv_btn_setting_kb_ring.setVisibility(View.GONE);
                                        bIsChanged = false;
                                        message = handler.obtainMessage();
                                        message.what = 0;
                                        message.arg1 = (int) paramsFloatLogo.x;
                                        message.arg2 = (int) paramsFloatLogo.y;
                                        handler.sendMessageDelayed(message, MENU_STAY_TIME);
                                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                                        {
                                            if(bIsVirtualMouseShowBackup)
                                            {
                                                windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                                                bIsVirtualMouseShow = true;
                                            }
                                        }
                                    }
                                })
                                .setNegativeButton(getResources().getString(R.string.string_pop_button_setting_exit_not_save), new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        if(bIsKBFloatMenuShow)
                                        {
                                            windowManager.removeView(kb_float_menu_layout);
                                            bIsKBFloatMenuShow = false;
                                        }
                                        if(bIsBtnPosEdit)
                                        {
                                            windowManager.removeView(button_pos_edit_layout);
                                            bIsBtnPosEdit = false;
                                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_EDIT_MODE,0,0,3);
                                        }
                                        if(bIsBtnPreShowTemp) {
                                            if(!bIsBtnPreShow) {
                                                windowManager.addView(button_preview_notouch_layout, paramsBtnPre);
                                                bIsBtnPreShow = true;
                                            }
                                        }
                                        else
                                        {
                                            if(bIsBtnPreShow)
                                            {
                                                windowManager.removeView(button_preview_notouch_layout);
                                                bIsBtnPreShow = false;
                                            }
                                        }
                                        windowManager.addView(float_menu_layout, paramsFloatMenu);
                                        bIsFloatMenuShow = true;

                                        kb_float_menu_layout_cancel.performClick();
                                        /*
                                        showFloatImage();
                                        iv_btn_setting_kb_ring.setVisibility(View.GONE);
                                        bIsChanged = false;

                                         */
                                    }
                                })
                                .setNeutralButton(getResources().getString(R.string.string_pop_cancel), new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {

                                    }
                                });
                        mDialog = builder.create();
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                            if (Settings.canDrawOverlays(FloatMenuService_New.this))
                                mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
                        } else {
                            mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
                        }
                        mDialog.show();
                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                        {
                            if(bIsVirtualMouseShowBackup)
                            {
                                windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                                bIsVirtualMouseShow = true;
                            }
                        }
                    }
                    else
                    {
                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                        {
                            if(bIsVirtualMouseShow)
                            {
                                windowManager.removeView(virtual_mouse_layout);
                                bIsVirtualMouseShowBackup = true;
                                bIsVirtualMouseShow = false;
                            }
                            else
                            {
                                bIsVirtualMouseShowBackup = false;
                            }
                        }
                        if(bIsKBFloatMenuShow)
                        {
                            windowManager.removeView(kb_float_menu_layout);
                            bIsKBFloatMenuShow = false;
                        }
                        if(bIsBtnPosEdit)
                        {
                            windowManager.removeView(button_pos_edit_layout);
                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_EDIT_MODE,0,0,3);
                            bIsBtnPosEdit = false;
                        }
                        if(bIsBtnPreShowTemp) {
                            if(!bIsBtnPreShow) {
                                windowManager.addView(button_preview_notouch_layout, paramsBtnPre);
                                bIsBtnPreShow = true;
                            }
                        }
                        windowManager.addView(float_menu_layout, paramsFloatMenu);
                        bIsFloatMenuShow = true;
                        showFloatImage();
                        message = handler.obtainMessage();
                        message.what = 0;
                        message.arg1 = (int) paramsFloatLogo.x;
                        message.arg2 = (int) paramsFloatLogo.y;
                        handler.sendMessageDelayed(message, MENU_STAY_TIME);
                        if(mGlobalVar.getIsSupportVirtualMouse_KB())
                        {
                            if(bIsVirtualMouseShowBackup)
                            {
                                windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                                bIsVirtualMouseShow = true;
                            }
                        }
                    }
                    break;
                case R.id.iv_kb_button_setting_add:
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShow)
                        {
                            windowManager.removeView(virtual_mouse_layout);
                            bIsVirtualMouseShowBackup = true;
                            bIsVirtualMouseShow = false;
                        }
                        else
                        {
                            bIsVirtualMouseShowBackup = false;
                        }
                    }
                    if(bIsEmptyIconShow)
                    {
                        showNormalEmptyBtn(false);
                    }
                    else
                    {
                        showNormalEmptyBtn(true);
                    }
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShowBackup)
                        {
                            windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                            bIsVirtualMouseShow = true;
                        }
                    }
                    break;
                case R.id.kb_float_menu_layout_attr:
                    showKBAdvanceSetting();
                    break;
                case R.id.btn_kb_float_position_data_save:
                    saveUserGameData();
                    break;
                case R.id.btn_kb_float_position_data_load:
                    loadUserGameData();
                    break;
                case R.id.iv_kb_button_setting_macro_zoom:
                    if (bIsSubViewOn) {
                        ViewGroup.LayoutParams adv_lp = kb_button_setting_macro_layout.getLayoutParams();
                        adv_lp.height = dip2px(FloatMenuService_New.this, 30);
                        kb_button_setting_macro_sub_layout.setVisibility(View.GONE);
                        iv_kb_button_setting_macro_zoom.setImageResource(R.drawable.zoom_up);
                        bIsSubViewOn = false;
                    } else {
                        ViewGroup.LayoutParams adv_lp = kb_button_setting_macro_layout.getLayoutParams();
                        adv_lp.height = panelHeight / 2;
                        kb_button_setting_macro_sub_layout.setVisibility(View.VISIBLE);
                        iv_kb_button_setting_macro_zoom.setImageResource(R.drawable.zoom_down);
                        bIsSubViewOn = true;
                    }
                    break;
                case R.id.btn_kb_button_setting_macro_confirm:
                    bIsMacro_record = false;
                    bIsMacroChange = true;
                    kb_button_setting_macro_layout.setVisibility(View.GONE);
                    if(!bIsKBFloatMenuShow) {
                        windowManager.addView(kb_float_menu_layout, paramsKBFloatMenu);
                        bIsKBFloatMenuShow = true;
                    }
                    tv_kb_attr_setting_pop_macro_desc.setText(parseTempAutoEvent());
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShow)
                        {
                            windowManager.removeView(virtual_mouse_layout);
                            bIsVirtualMouseShowBackup = true;
                            bIsVirtualMouseShow = false;
                        }
                        else
                        {
                            bIsVirtualMouseShowBackup = false;
                        }
                    }
                    mDialog.show();
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShowBackup)
                        {
                            windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                            bIsVirtualMouseShow = true;
                        }
                    }
                    break;
                case R.id.btn_button_setting_macro_edit_cancel:
                    //System.arraycopy(g_u8TempAutoEventTbl, 0, g_u8tAutoEventTbl, (g_u8tAttrTable[g_u8ButtonID][1] & 0xFF), g_u8ActionTblLen);
                    //System.arraycopy(tempAttrEvTbl,tempAttrTbl[1][1],tempAttrEvTblEdit,0,tempAttrTbl[1][2]);
                    if(bIsMacroBackup)
                    {
                        tempAttrTblEdit[2] = g_mAutoEventTblLen = tempAttrTblEdit_bk[2];
                        System.arraycopy(tempAttrEvTblEdit_bk,0,tempAttrEvTblEdit,0,g_mAutoEventTblLen);
                    }
                    else
                    {
                        System.arraycopy(tempAttrEvTbl,tempAttrTblEdit[1],tempAttrEvTblEdit,0,tempAttrTblEdit[2]);
                        g_mAutoEventTblLen = 0;
                    }
                    windowManager.removeView(layout_button_setting_macro_edit);
                    if(bIsMacroBackup)
                        tv_kb_attr_setting_pop_macro_desc.setText(parseTempAutoEvent());
                    else
                        tv_kb_attr_setting_pop_macro_desc.setText(parseAutoEvent(g_preButtonIndex));

                    bIsMacroBackup =  false;
                    g_bIsVirtualEdit = false;
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShow)
                        {
                            windowManager.removeView(virtual_mouse_layout);
                            bIsVirtualMouseShowBackup = true;
                            bIsVirtualMouseShow = false;
                        }
                        else
                        {
                            bIsVirtualMouseShowBackup = false;
                        }
                    }
                    mDialog.show();
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShowBackup)
                        {
                            windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                            bIsVirtualMouseShow = true;
                        }
                    }
                    break;
                case R.id.btn_button_setting_macro_edit_confirm:
                    bIsMacroChange = true;
                    windowManager.removeView(layout_button_setting_macro_edit);
                    //windowManager.addView(btnFloatLayout, paramsFloat);
                    //windowManager.addView(button_setting_layout, paramsButtonSetting);
                    //windowManager.addView(layout_advance_setting, paramsAdvance);
                    if(g_bIsVirtualEdit)
                        tv_kb_attr_setting_pop_macro_desc.setText(parseTempAutoEvent());
                    else
                        tv_kb_attr_setting_pop_macro_desc.setText(parseTempAutoEvent());
                    g_bIsVirtualEdit = false;
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShow)
                        {
                            windowManager.removeView(virtual_mouse_layout);
                            bIsVirtualMouseShowBackup = true;
                            bIsVirtualMouseShow = false;
                        }
                        else
                        {
                            bIsVirtualMouseShowBackup = false;
                        }
                    }
                    mDialog.show();
                    if(mGlobalVar.getIsSupportVirtualMouse_KB())
                    {
                        if(bIsVirtualMouseShowBackup)
                        {
                            windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                            bIsVirtualMouseShow = true;
                        }
                    }
                    break;
            }
        }
    };

    void saveUserGameData()
    {
        if(mGlobalVar.getIsSupportVirtualMouse_KB())
        {
            if(bIsVirtualMouseShow)
            {
                windowManager.removeView(virtual_mouse_layout);
                bIsVirtualMouseShowBackup = true;
                bIsVirtualMouseShow = false;
            }
            else
            {
                bIsVirtualMouseShowBackup = false;
            }
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(FloatMenuService_New.this);
        final EditText editText = new EditText(FloatMenuService_New.this);
        editText.setHint(mGlobalVar.curLabelName);
        editText.setSingleLine();
        builder.setTitle(getResources().getString(R.string.string_pop_data_save_dialog_filename))
                .setView(editText)
                .setMessage(getResources().getString(R.string.string_pop_data_save_dialog_input_filename))
                .setPositiveButton(getResources().getString(R.string.string_pop_confirm), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        String strFileName = mGlobalVar.curLabelName;

                        if (!android.text.TextUtils.isEmpty(editText.getText()))
                            strFileName = editText.getText().toString();

                        //mGlobalVar.getCoordinateFromDevice_KB();
                        //mGlobalVar.getAttributeFromDevice_KB();
                        //mGlobalVar.getAttributeEventTableFromDevice_KB();
                        //bIsMacroChange = false;
                        JSONArray jsonArray = new JSONArray();
                        for (int a=0;a<Transfer_Con.MAX_COORDINATE*2;a++) {
                            jsonArray.put(mGlobalVar.coorTbl[a]);
                        }

                        for(int a=0;a<Transfer_Con.MAX_COORDINATE;a++) {
                            for (int k=0;k<3;k++) {
                                jsonArray.put(mGlobalVar.attrTbl[a][k]);

                            }
                        }
                        for (int a=0;a<Transfer_Con.MAX_AUTOEVENT_LENGTH_KB;a++) {
                            jsonArray.put(mGlobalVar.attrEvTbl[a]);
                        }
                        if (Build.VERSION.SDK_INT >= 26 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                                != PackageManager.PERMISSION_GRANTED) {
                                Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_float_menu_save_fail_permitted), Toast.LENGTH_SHORT).show();
                        } else {
                            if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {

                                String fileName = strFileName + ".caf";
                                if (mGlobalVar.writeFile(fileName, jsonArray.toString())) {
                                    Toast.makeText(FloatMenuService_New.this, strFileName + getResources().getString(R.string.string_pop_file_save_success), Toast.LENGTH_SHORT).show();
                                }

                            } else {
                                Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_file_save_fail), Toast.LENGTH_SHORT).show();
                            }
                        }
                    }
                });
                mDialog = builder.create();
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    if (Settings.canDrawOverlays(FloatMenuService_New.this))
                        mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
                } else {
                    mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
                }
                mDialog.show();
        if(mGlobalVar.getIsSupportVirtualMouse_KB())
        {
            if(bIsVirtualMouseShowBackup)
            {
                windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                bIsVirtualMouseShow = true;
            }
        }
    }

    void loadUserGameData()
    {
        if (Build.VERSION.SDK_INT >= 26 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_float_menu_save_fail_permitted), Toast.LENGTH_SHORT).show();
        } else {
            ArrayList<String> fileList = mGlobalVar.getFileList("caf");
            final String[] item = new String[fileList.size()];
            for(int a=0;a<fileList.size();a++)
                item[a] = fileList.get(a);
            if(mGlobalVar.getIsSupportVirtualMouse_KB())
            {
                if(bIsVirtualMouseShow)
                {
                    windowManager.removeView(virtual_mouse_layout);
                    bIsVirtualMouseShowBackup = true;
                    bIsVirtualMouseShow = false;
                }
                else
                {
                    bIsVirtualMouseShowBackup = false;
                }
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(FloatMenuService_New.this);
            builder.setTitle(getResources().getString(R.string.string_pop_data_save_dialog_input_filename))
                    .setItems(item, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            //Toast.makeText(MainActivity.this,String.valueOf(which),Toast.LENGTH_SHORT).show();
                            String fileName = item[which];
                            String content = mGlobalVar.readFile(fileName);
                            try {
                                JSONArray jsonArray = new JSONArray(content);
                                if(jsonArray.length()<=0)
                                    return;
                                String str="";
                                for(int a=0;a<Transfer_Con.MAX_COORDINATE*2;a++)
                                {
                                    mGlobalVar.coorTbl[a] = jsonArray.getInt(a);
                                   // str= str+String.valueOf(mGlobalVar.coorTbl[a])+", ";
                                }
                                //Log.d(TAG,str);
                               // str="";
                                for(int a=0;a<Transfer_Con.MAX_COORDINATE;a++)
                                {
                                    for(int i=0;i<3;i++)
                                    {
                                        mGlobalVar.attrTbl[a][i] = jsonArray.getInt(Transfer_Con.MAX_COORDINATE*2+a*3+i);
                                       str= str+String.valueOf(mGlobalVar.attrTbl[a][i])+", ";
                                    }
                                }
                                Log.d(TAG,str);
                                str="";
                                // Event table
                                if(jsonArray.length()>=(Transfer_Con.MAX_COORDINATE*5+Transfer_Con.MAX_AUTOEVENT_LENGTH_KB))
                                {
                                    for(int a=0;a<Transfer_Con.MAX_AUTOEVENT_LENGTH_KB;a++)    // coordinate
                                    {
                                        mGlobalVar.attrEvTbl[a] = jsonArray.getInt(Transfer_Con.MAX_COORDINATE*5+a);
                                        str= str+String.valueOf(mGlobalVar.attrEvTbl[a])+", ";
                                    }
                                }
                                else
                                {
                                    for(int a=0;a<Transfer_Con.MAX_AUTOEVENT_LENGTH_KB;a++)    // coordinate
                                    {
                                        mGlobalVar.attrEvTbl[a] = 0;
                                    }
                                }

                                Log.d(TAG,str);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                            mGlobalVar.sendCoordinateToDevice_KB();
                            mGlobalVar.sendAttributeToDevice_KB();
                            mGlobalVar.sendAttributeEventTableToDevice_KB();
                            //mGlobalVar.sendLocalSettingToDevice();
                            mGlobalVar.saveGameData_KB(mGlobalVar.curPkgName,mGlobalVar.curLabelName,mGlobalVar.coorTbl,mGlobalVar.attrTbl,mGlobalVar.attrEvTbl);
                            tempCoordinateTbl = mGlobalVar.coorTbl.clone();
                            tempAttrEvTbl = mGlobalVar.attrEvTbl.clone();
                            for(int k=0;k<Transfer_Con.MAX_COORDINATE;k++)
                            {
                                tempAttrTbl[k][0] = mGlobalVar.attrTbl[k][0];
                                tempAttrTbl[k][1] = mGlobalVar.attrTbl[k][1];
                                tempAttrTbl[k][2] = mGlobalVar.attrTbl[k][2];
                            }

                            for(int a=4;a<mGlobalVar.getDirectCenterIndex();a++)
                            {
                                if(tempAttrTbl[a][0] ==0x20)
                                {
                                    mGlobalVar.kbTbl[0] = (byte)a;
                                }
                                else if(tempAttrTbl[a][0] ==0x21)
                                {
                                    mGlobalVar.kbTbl[1] = (byte)a;
                                }
                                else if(tempAttrTbl[a][0] ==0x22)
                                {
                                    mGlobalVar.kbTbl[2] = (byte)a;
                                }
                                else if(tempAttrTbl[a][0] ==0x23)
                                {
                                    mGlobalVar.kbTbl[3] = (byte)a;
                                }
                                else if(tempAttrTbl[a][0] ==0x24)
                                {
                                    mGlobalVar.kbTbl[4] = (byte)a;
                                }
                            }

                            tempKbTbl = mGlobalVar.kbTbl.clone();

                            showFloatImage();
                        }
                    });
            mDialog = builder.create();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (Settings.canDrawOverlays(FloatMenuService_New.this))
                    mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
            } else {
                mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
            }
            mDialog.show();
            if(mGlobalVar.getIsSupportVirtualMouse_KB())
            {
                if(bIsVirtualMouseShowBackup)
                {
                    windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                    bIsVirtualMouseShow=true;
                }
            }
        }
    }


    public static int dip2px(Context context, float dipValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dipValue * scale + 0.5f);
    }
    View.OnTouchListener onTouchListener = new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction())
            {
                case MotionEvent.ACTION_DOWN:
                    handler.removeMessages(0);
                    break;
                case MotionEvent.ACTION_MOVE:
                    break;
                case MotionEvent.ACTION_UP:
                    message = handler.obtainMessage();
                    message.what = 0;
                    message.arg1 = (int) paramsFloatLogo.x;
                    message.arg2 = (int) paramsFloatLogo.y;
                    handler.sendMessageDelayed(message, MENU_STAY_TIME);
                    //Log.d(TAG,"222222222222222222222222");
                    break;
            }
            return false;
        }
    };

    public void showWin()
    {
        WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        DisplayMetrics dm = new DisplayMetrics();
        display.getRealMetrics(dm);
        //Log.d(TAG, String.format("Show wid=%d, hei=%d", dm.widthPixels, dm.heightPixels));
        if((panelHeight!=dm.heightPixels)||(panelWidth!=dm.widthPixels)) {
            panelHeight = dm.heightPixels;
            panelWidth = dm.widthPixels;

            if (panelWidth < panelHeight) {
                int a = panelWidth;
                panelWidth = panelHeight;
                panelHeight = a;
                // Log.d(TAG, "swap to Landscape Mode");
            }
        }
        if(Transfer_Con.ENABLE_DIFFERENT_RESOLUTION_KB) {
            /*
            if ((mGlobalVar.getScreenWidth() != panelHeight) && ((panelHeight == 1128) || (panelHeight == 752))) {
                panelHeight = mGlobalVar.getScreenWidth();
            }

            if ((mGlobalVar.getScreenHeight() != panelWidth) && ((panelWidth == 2400) || (panelWidth == 1600))) {
                panelWidth = mGlobalVar.getScreenHeight();
            }

             */
            if(getIsHDMIOut())
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_SCREEN_RESOLUTION, panelWidth, panelHeight,3);
        }
        if(!bIsFloatLogoShow) {
            // if (!mGlobalVar.getIsSettingServiceRunning())
            {
                windowManager.addView(float_Logo_Layout, paramsFloatLogo);
                bIsFloatLogoShow = true;
                if (bIsHalfShow) {
                    float_Logo_Layout.scrollBy(0, -floatLogoSize/2);
                    windowManager.updateViewLayout(float_Logo_Layout, paramsFloatLogo);
                    bIsHalfShow = false;
                }
                message = handler.obtainMessage();
                message.what = 0;
                message.arg1 = (int) paramsFloatMenu.x;
                message.arg2 = (int) paramsFloatMenu.y;
                handler.sendMessageDelayed(message, MENU_STAY_TIME);
            }
        }
        if(!bIsFloatMenuShow)
        {
            windowManager.addView(float_menu_layout, paramsFloatMenu);
            bIsFloatMenuShow = true;
        }

        if(bIsBtnPreShowTemp)
        {
            if(!bIsBtnPreShow) {
                windowManager.addView(button_preview_notouch_layout, paramsBtnPre);
                bIsBtnPreShow = true;
            }
        }
        tempCoordinateTbl = mGlobalVar.coorTbl.clone();
        for(int k=0;k<Transfer_Con.MAX_COORDINATE;k++)
        {
            tempAttrTbl[k][0] = mGlobalVar.attrTbl[k][0];
            tempAttrTbl[k][1] = mGlobalVar.attrTbl[k][1];
            tempAttrTbl[k][2] = mGlobalVar.attrTbl[k][2];
        }
        tempKbTbl = mGlobalVar.kbTbl.clone();
        mImageHalfSize = (int)(((float)dip2px(this,7)*(mGlobalVar.getNormal_Icon_Size() + 5) / 10));
        mImageHalfSizeEdit = (int)(((float)dip2px(this,10)*(mGlobalVar.getPt_Tbl_View_Size() + 5) / 10));
        mImageHalfSizeDirect= (int)(((float)dip2px(this,12)*(mGlobalVar.getNormal_Icon_Size() + 5) / 10));
        showFloatImage();
        if(Transfer_Con.ENABLE_DEVICE_STATUS_POLLING)
        {
            if (mGlobalVar.getIsSupportShotHelpPosture_KB()) {
                messageStatus = handlerStatus.obtainMessage();
                messageStatus.what = 0;
                messageStatus.arg1 = 1;
                messageStatus.arg2 = 2;
                handlerStatus.sendMessageDelayed(messageStatus, 1000);//MENU_STAY_TIME);
                if(mGlobalVar.getIsSupportVirtualMouse_KB()) {
                    if (mGlobalVar.getIsUseVirtualMouse())
                        mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_GAME_MODE, 0xA55AB44B, 1, 10);
                }
            }
        }
    }

    public void hideWin()
    {
        if(bIsFloatLogoShow) {
            handler.removeMessages(0);
            windowManager.removeView(float_Logo_Layout);
            bIsFloatLogoShow = false;
            if (bIsBtnPreShow) {
                windowManager.removeView(button_preview_notouch_layout);
                bIsBtnPreShow = false;
            }
            if(bIsFloatMenuShow) {
                windowManager.removeView(float_menu_layout);
                bIsFloatMenuShow = false;
            }
            if(bIsKBFloatMenuShow)
            {
                windowManager.removeView(kb_float_menu_layout);
                bIsKBFloatMenuShow = false;
            }
            if(bIsQuickSettingShow) {
                windowManager.removeView(kb_Quick_Setting_Layout);
                bIsQuickSettingShow = false;
            }
            if(bIsPositionDataShow)
            {
                bIsPositionDataShow = false;
                windowManager.removeView(kb_position_data_layout);
            }
            if(bIsBtnPosEdit)
            {
                windowManager.removeView(button_pos_edit_layout);
                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_EDIT_MODE,0,0,3);
                bIsBtnPosEdit = false;
            }
            if(Transfer_Con.ENABLE_DEVICE_STATUS_POLLING)
            {
                if(mGlobalVar.getIsSupportShotHelpPosture_KB()) {
                    if(handlerStatus!=null)
                        handlerStatus.removeMessages(0);
                    if (bIsFloatStatusShow) {
                        windowManager.removeView(float_status_layout);
                        bIsFloatStatusShow = false;
                    }
                    if(mGlobalVar.getIsSupportVirtualMouse_KB()) {
                        if (mGlobalVar.getIsUseVirtualMouse()) {
                            mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_GAME_MODE, 0xA55AB44B, 0, 10);
                            mGlobalVar.tranGet_Value_status(Transfer_Con.HID_CMD_GET_STATUS, 0, 0, u8DataBuffer);
                        }
                    }
                    if(bIsVirtualMouseShow) {
                        windowManager.removeView(virtual_mouse_layout);
                        bIsVirtualMouseShow = false;
                    }
                }
            }
        }
    }

    void saveAVEData(int index)
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED)
        {
            Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_float_menu_save_fail_permitted), Toast.LENGTH_SHORT).show();
        }
        else
        {
            if(mGlobalVar.getIsSupportVirtualMouse_KB())
            {
                if(bIsVirtualMouseShow)
                {
                    windowManager.removeView(virtual_mouse_layout);
                    bIsVirtualMouseShowBackup = true;
                    bIsVirtualMouseShow = false;
                }
                else
                {
                    bIsVirtualMouseShowBackup = false;
                }
            }
            final String strDefFileName = Transfer_Con.tKeyName[index]+getResources().getString(R.string.string_pop_button_advance_title_attr);
            AlertDialog.Builder builder = new AlertDialog.Builder(FloatMenuService_New.this);
            final EditText editText = new EditText(FloatMenuService_New.this);
            editText.setHint(strDefFileName);
            editText.setSingleLine();
            builder.setTitle(getResources().getString(R.string.string_pop_button_advance_export_key_attr))
                    .setView(editText)
                    .setMessage(getResources().getString(R.string.string_pop_data_save_dialog_input_filename))
                    .setPositiveButton(getResources().getString(R.string.string_pop_confirm), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                            String strFileName = strDefFileName;
                            if (!android.text.TextUtils.isEmpty(editText.getText()))
                                strFileName = editText.getText().toString();
                            strFileName += ".kbe";

                            JSONArray jsonArray = new JSONArray();
                            jsonArray.put(tempAttrTblEdit[0]);
                            jsonArray.put(tempAttrTblEdit[1]);
                            jsonArray.put(tempAttrTblEdit[2]);
                            for (int a=0;a<tempAttrTblEdit[2]; a++) {
                                jsonArray.put(tempAttrEvTblEdit[(tempAttrTblEdit[1])+a]);
                            }
                            if (mGlobalVar.writeFile(strFileName, jsonArray.toString())) {
                                Toast.makeText(FloatMenuService_New.this, strFileName + getResources().getString(R.string.string_pop_file_save_success), Toast.LENGTH_SHORT).show();
                            }
                        }
                    })
                    .setNegativeButton(getResources().getString(R.string.string_pop_cancel), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });
            final AlertDialog dialog = builder.create();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (Settings.canDrawOverlays(FloatMenuService_New.this))
                    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
            } else {
                dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
            }
            dialog.show();
            if(mGlobalVar.getIsSupportVirtualMouse_KB())
            {
                if(bIsVirtualMouseShowBackup)
                {
                    windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                    bIsVirtualMouseShow = true;
                }
            }
        }
    }

    void loadAEVData(final int index)
    {
        if (Build.VERSION.SDK_INT >= 26 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_float_menu_save_fail_permitted), Toast.LENGTH_SHORT).show();
        } else {
            ArrayList<String> fileList = mGlobalVar.getFileList("kbe");
            final String[] item = new String[fileList.size()];
            for(int a=0;a<fileList.size();a++)
                item[a] = fileList.get(a);
            if(mGlobalVar.getIsSupportVirtualMouse_KB())
            {
                if(bIsVirtualMouseShow)
                {
                    windowManager.removeView(virtual_mouse_layout);
                    bIsVirtualMouseShowBackup = true;
                    bIsVirtualMouseShow = false;
                }
                else
                {
                    bIsVirtualMouseShowBackup = false;
                }
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(FloatMenuService_New.this);
            builder.setTitle(getResources().getString(R.string.string_pop_data_save_dialog_input_filename))
                    .setItems(item, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            //Toast.makeText(MainActivity.this,String.valueOf(which),Toast.LENGTH_SHORT).show();
                            String fileName = item[which];
                            String content = mGlobalVar.readFile(fileName);
                            try {
                                JSONArray jsonArray = new JSONArray(content);
                                for(int a=0;a<3;a++)
                                {
                                    tempAttrTblEdit[a] = (byte)jsonArray.getInt(a);
                                }
                                for(int a=3;a<jsonArray.length();a++)
                                {
                                    tempAttrEvTblEdit[a-3] = (byte)jsonArray.getInt(a);
                                }
                                tempAttrTblEdit[0] =(byte)(tempAttrTblEdit[0]|0x80);
                                g_mAutoEventTblLen=tempAttrTblEdit[2];

                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            // tv_advance_setting_macro_btn_desc.setText(parseTempAutoEvent());
                            submit_tempAttrEvTable(index);
                            bIsMacroChange = true;
                        }
                    });
            final AlertDialog dialog = builder.create();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (Settings.canDrawOverlays(FloatMenuService_New.this))
                    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
            } else {
                dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
            }
            dialog.show();
            if(mGlobalVar.getIsSupportVirtualMouse_KB())
            {
                if(bIsVirtualMouseShowBackup)
                {
                    windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                    bIsVirtualMouseShow = true;
                }
            }
        }
    }
    String[] files;
    public String[] getfileFromAssets(String path) {
        AssetManager assetManager = FloatMenuService_New.this.getAssets();
        try {
            files = assetManager.list(path);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return files;
    }



    void loadAEVFixData(final int index)
    {
        if (Build.VERSION.SDK_INT >= 26 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            Toast.makeText(FloatMenuService_New.this, getResources().getString(R.string.string_pop_float_menu_save_fail_permitted), Toast.LENGTH_SHORT).show();
        } else {

            String str="wzry";
            if(mGlobalVar.getmCurGame()==0)
            {
                str ="hpjy";
            }
            else
            {
                str ="wzry";
            }
            files = getfileFromAssets(str);
            final String strSub= str;
            final String[] item = new String[files.length];
            System.arraycopy(files,0,item,0,files.length);
            if(mGlobalVar.getIsSupportVirtualMouse_KB())
            {
                if(bIsVirtualMouseShow)
                {
                    windowManager.removeView(virtual_mouse_layout);
                    bIsVirtualMouseShowBackup = true;
                    bIsVirtualMouseShow = false;
                }
                else
                {
                    bIsVirtualMouseShowBackup = false;
                }
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(FloatMenuService_New.this);
            builder.setTitle(getResources().getString(R.string.string_pop_data_save_dialog_input_filename))
                    .setItems(item, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                            String fileName =strSub+"/"+ item[which];
                            //String content = mGlobalVar.readFile(fileName);
                            //Toast.makeText(ButtonSettingService.this,fileName,Toast.LENGTH_SHORT).show();
                            if(BuildConfig.DEBUG)
                                Log.d(TAG,fileName);
                            String content = null;
                            InputStream is = null;
                            try {

                                is = getResources().getAssets().open(fileName);
                                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                                byte[] buffer = new byte[1024];
                                int len = -1;
                                while ((len = is.read(buffer)) != -1) {
                                    baos.write(buffer, 0, len);
                                }
                                content = baos.toString();
                                is.close();
                            } catch (FileNotFoundException e) {
                                e.printStackTrace();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                            try {
                                JSONArray jsonArray = new JSONArray(content);
                                for(int a=0;a<3;a++)
                                {
                                    tempAttrTblEdit[a] = (byte)jsonArray.getInt(a);
                                }
                                for(int a=3;a<jsonArray.length();a++)
                                {
                                    tempAttrEvTblEdit[a-3] = (byte)jsonArray.getInt(a);
                                }


                                tempAttrTblEdit[0] =(byte)(tempAttrTblEdit[0]|0x80);
                                g_mAutoEventTblLen=tempAttrTblEdit[2];

                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            // tv_advance_setting_macro_btn_desc.setText(parseTempAutoEvent());
                            submit_tempAttrEvTable(index);
                            bIsMacroChange = true;
                        }
                    });
            final AlertDialog dialog = builder.create();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (Settings.canDrawOverlays(FloatMenuService_New.this))
                    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
            } else {
                dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
            }
            dialog.show();
            if(mGlobalVar.getIsSupportVirtualMouse_KB())
            {
                if(bIsVirtualMouseShowBackup)
                {
                    windowManager.addView(virtual_mouse_layout,paramsVirtualMouse);
                    bIsVirtualMouseShow = true;
                }
            }
        }
    }


    class FMSN_BroadcastReceive extends BroadcastReceiver
    {
        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub

            String action=intent.getAction();
            Log.d(TAG,"Action: "+action);
            //Toast.makeText(FloatMenuService_New.this,action,Toast.LENGTH_SHORT).show();
            if("android.intent.action.CONFIGURATION_CHANGED".equals(action)) {
                Configuration mConfiguration = context.getResources().getConfiguration(); //获取设置的配置信息
                int ori = mConfiguration.orientation; //获取屏幕方向
                if(g_prvOrientation!=ori) {
                    if (ori == Configuration.ORIENTATION_LANDSCAPE) {
                        //横屏
                        Log.d(TAG, "横屏 " + String.valueOf(ori));
                        showWin();
                    } else if (ori == Configuration.ORIENTATION_PORTRAIT) {
                        //竖屏
                        Log.d(TAG, "竖屏 " + String.valueOf(ori));
                        hideWin();
                        //stopSelf();
                    }
                }
                g_prvOrientation = ori;
            }

            if(UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action))
            {
                if(mGlobalVar.enumDevice()<1) {
                    mGlobalVar.setbIsUsbConnect(false);
                    mGlobalVar.setbIsTransferMode(false);
                    mGlobalVar.myUsbDevice = null;
                    mGlobalVar.myInterface = null;
                    mGlobalVar.epOut = null;
                    mGlobalVar.epIn = null;
                    mGlobalVar.clear_IntVersion();
                /*
                byte []data = new byte[4];
                data[0] = 0x10;
                data[1] = 0;
                udpSocketHelper.sendCmd(data,2);
                */
                    stopSelf();
                }else if(mGlobalVar.getDeviceIndex()==Transfer_Con.DEVICE_BX2_INDEX)
                {
                    if(cb_kb_float_quick_setting_audio.isChecked())
                    {
                        audioManager.setMode(AudioManager.MODE_NORMAL);
                        cb_kb_float_quick_setting_audio.setChecked(false);
                        if(Transfer_Con.ENABLE_POLLING_AUDIO_TO_HEADSET)
                        {
                            handlerAudio.removeMessages(0);
                        }
                    }
                }
            }
            if("android.intent.action.HEADSET_PLUG".equals(action))
            {
                if (intent.hasExtra("state")) {
                    if (0 == intent.getIntExtra("state", 0)) {
                        //Toast.makeText(context, "耳机未插入", Toast.LENGTH_SHORT).show();
                        bIsHeadSetPlugIn =  false;
                        if(mGlobalVar.getIsAudioOut())
                            audioManager.setMode(AudioManager.MODE_NORMAL);
                    } else if (1 == intent.getIntExtra("state", 0)) {
                        //Toast.makeText(context, "耳机已插入", Toast.LENGTH_SHORT).show();
                        bIsHeadSetPlugIn =  true;
                    }
                }
            }

            if("com.opd.soeghtool.content".equals(action))
            {
                String name = intent.getStringExtra("Guide");
                if(name.equals("Float"))
                {
                    mGlobalVar.setIsFloatMenuGuide(false);
                    SharedPreferences.Editor editor = getSharedPreferences(Transfer_Con.SAVENAME, MODE_PRIVATE).edit();
                    editor.putBoolean("FloatMenu", mGlobalVar.getIsFloatMenuGuide());
                    editor.apply();
                    message = handler.obtainMessage();
                    message.what = 0;
                    message.arg1 = (int) paramsFloatMenu.x;
                    message.arg2 = (int) paramsFloatMenu.y;
                    handler.sendMessageDelayed(message, MENU_STAY_TIME);
                }
            }
            if("com.opd.soeghtool.floatview".equals(action))
            {
                String name = intent.getStringExtra("Visibility");
                if(name.equals("Show"))
                {
                    showWin();
                }
                else if(name.equals("Hide"))
                {
                    hideWin();
                }
            }
        /*
            if (action.equals("android.intent.action.HDMI_PLUGGED")) {
                boolean state = intent.getBooleanExtra("state", false);
                if (state) {
                    Log.d(TAG,"------------->HDMI Connect");
                } else {
                    Log.d(TAG,"------------->HDMI DisConnect");
                }
            }*/
        }
    }

    public boolean getIsHDMIOut()
    {
        if(mediaRouter!=null)
        {
            CharSequence strName = "HDMI";
            if(mediaRouter.getDefaultRoute().getPresentationDisplay()!=null)
            {
                if(mediaRouter.getDefaultRoute().getPresentationDisplay().getName().contains(strName))
                {
                    Display display = mediaRouter.getDefaultRoute().getPresentationDisplay();
                    Point point =new Point();
                    display.getRealSize(point);
                    HDMI_Width = point.x;
                    HDMI_Height = point.y;
                    return true;
                }
            }

        }
        HDMI_Width = panelWidth;
        HDMI_Height = panelHeight;
        return false;
    }

    public boolean getIsHDMIOut1()
    {
        if(mediaRouter!=null)
        {
            CharSequence strName = "HDMI";
            if(mediaRouter.getDefaultRoute().getPresentationDisplay()!=null) {
                if (mediaRouter.getDefaultRoute().getPresentationDisplay().getName().contains(strName)) {
                    Display display = mediaRouter.getDefaultRoute().getPresentationDisplay();
                    if (display != null) {
                        return true;
                    }
                }
            }
        }
        return false;
    }



    @Override
    public void onDestroy()
    {
        handler.removeMessages(0);
        if(Transfer_Con.ENABLE_OPPO_MSG_HANDLE) {
            if (android.os.Build.BRAND.equalsIgnoreCase("OPPO")) {
                handlerSystem.removeMessages(0);
            }
        }
        if(mDialog!=null)
            mDialog.dismiss();
        unregisterReceiver(fmsnBroadcastReceive);
        mGlobalVar.setIsFloatServiceRunning(false);
        if(bIsBtnPreShow)
        {
            windowManager.removeView(button_preview_notouch_layout);
        }
        if(bIsFloatMenuShow)
        {
            windowManager.removeView(float_menu_layout);
        }
        if(bIsQuickSettingShow)
        {
            windowManager.removeView(kb_Quick_Setting_Layout);
        }
        if(bIsPositionDataShow)
        {
            windowManager.removeView(kb_position_data_layout);
        }
        if(bIsFloatLogoShow) {
            windowManager.removeView(float_Logo_Layout);
        }
        if(bIsKBFloatMenuShow)
        {
            windowManager.removeView(kb_float_menu_layout);
            bIsKBFloatMenuShow = false;
        }
        if(bIsBtnPosEdit)
        {
            windowManager.removeView(button_pos_edit_layout);
            bIsBtnPosEdit = false;
        }
        if(Transfer_Con.ENABLE_POLLING_AUDIO_TO_HEADSET)
        {
            if(handlerAudio!=null)
                handlerAudio.removeMessages(0);
        }
        if(Transfer_Con.ENABLE_DEVICE_STATUS_POLLING)
        {
            //if(Transfer_Con.ENABLE_VIRTUAL_MOUSE)
            {
                if(handlerStatus!=null)
                    handlerStatus.removeMessages(0);
                if (bIsFloatStatusShow) {
                    windowManager.removeView(float_status_layout);
                    bIsFloatStatusShow = false;
                }
                if (bIsVirtualMouseShow) {
                    windowManager.removeView(virtual_mouse_layout);
                    bIsVirtualMouseShow = false;
                }
            }
        }
        mediaRouter.removeCallback(mMediaRouterCallback);
        super.onDestroy();
    }



    private final MediaRouter.SimpleCallback mMediaRouterCallback = new MediaRouter.SimpleCallback() {
        @Override
        public void onRouteChanged(MediaRouter router, MediaRouter.RouteInfo info) {
            super.onRouteChanged(router,info);
            //Toast.makeText(FloatMenuService_New.this,"onRouteChanged: "+router.getDefaultRoute().getPresentationDisplay()+"     info:"+info.toString(),Toast.LENGTH_SHORT).show();
            //Log.d(TAG,"onRouteChanged: "+router.getDefaultRoute().getPresentationDisplay()+"     info:"+info.toString());
            if(mGlobalVar.getIsCurDeviceKBBox()) {
                if (router != null) {
                    CharSequence strName = "HDMI";
                    if (router.getDefaultRoute().getPresentationDisplay() != null) {
                        if (router.getDefaultRoute().getPresentationDisplay().getName().contains(strName)) {
                            Display display = router.getDefaultRoute().getPresentationDisplay();
                            Point point = new Point();
                            display.getRealSize(point);
                            HDMI_Width = point.x;
                            HDMI_Height = point.y;
                            bIsAutoModeHDMIOut = true;
                            if (mGlobalVar.getIsAutoSwitchToHDMI()) {
                                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HDMI_RESOLUTION, HDMI_Width, HDMI_Height, 3);
                                mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x04, 0x04, 3);
                            }
                            return;
                        }
                    }
                }
                {
                    HDMI_Width = 1920;
                    HDMI_Width = 1080;
                    bIsAutoModeHDMIOut = false;
                    if (mGlobalVar.getIsAutoSwitchToHDMI()) {
                        mGlobalVar.tranSet_Value_retry(Transfer_Con.HID_CMD_SET_HW_SETTING, 0x00, 0x04, 3);
                    }
                }
            }
        }
    };
}
